dhii / cqrs-resource-model-interface

资源模型CQRS方法的接口。

v0.2-alpha1 2018-06-25 16:35 UTC

This package is auto-updated.

Last update: 2024-09-07 02:58:39 UTC


README

Build Status Code Climate Test Coverage Latest Stable Version This package complies with Dhii standards

详细信息

资源模型的CQRS方法接口。

接口

  • SelectCapableInterface - 可以从存储中检索记录的对象接口,可选地限制结果仅限于满足给定条件的记录,该条件表示为任意树形式的表达式
  • InsertCapableInterface - 可以将一个或多个记录插入存储的对象接口。支持各种容器类型。
  • UpdateCapableInterface - 可以更新存储中记录的对象接口,可选地限制为满足给定条件的记录,该条件表示为任意树形式的表达式
  • DeleteCapableInterface - 可以从存储中删除记录的对象接口,可选地限制为满足给定条件的记录,该条件表示为任意树形式的表达式

用法

use Dhii\Storage\Resource\SelectCapableInterface;
use Dhii\Collection\MapInterface;

/* @var $select SelectCapableInterface */
$results = $select->select();

/* The below would go through each element of the result set, and,
 * if the 'age' field is greater than 18, output all of the names
 * and values of all fields.
 */
foreach ($results as $_result) {
  /* @var $_result MapInterface */
  if ((int) $_result->get('age') < 18) {
    continue;
  }
  
  foreach ($_result as $_field => $_value) {
    echo sprintf('%1$s: %2$s', $_field, $_value) . "\n";
  }
  
  echo "---' . "\n";
}