dhii / cqrs-resource-model-interface
Interfaces for a CQRS approach to resource models.
Installs: 2 231
Dependents: 9
Suggesters: 1
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^5.3 | ^7.0
Requires (Dev)
- codeclimate/php-test-reporter: <=0.3.2
- dhii/collections-interface: ^0.2-alpha1
- dhii/expression-interface: ^0.2
- dhii/php-cs-fixer-config: dev-php-5.3
- dhii/sql-interface: ^0.1
- dhii/stringable-interface: ^0.1
- phpunit/phpunit: ^4.8
- psr/container: ^1.0
- ptrofimov/xpmock: ^1.1
Suggests
- dhii/expression-interface: To create query conditions and value expressions.
- dhii/stringable-interface: To pass stringable objects in place of strings.
This package is auto-updated.
Last update: 2024-10-07 03:14:51 UTC
README
Details
Interfaces for a CQRS approach to resource models.
Interfaces
SelectCapableInterface
- Interface for objects that can retrieve records from storage, optionally limiting the result to only records that satisfy a given condition represented as an arbitrary tree of expressions.InsertCapableInterface
- Interface for objects that can insert one or more records into storage. Various container types are supported.UpdateCapableInterface
- Interface for objects that can update records in storage, optionally limited to records that satisfy a given condition represented as an arbitrary tree of expressions.DeleteCapableInterface
- Interface for objects that can delete records from storage, optionally limited to records that satisfy a given condition represented as an arbitrary tree of expressions.
Usage
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"; }