PHP code example of infinite-networks / specifications
1. Go to this page and download the library: Download infinite-networks/specifications library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
infinite-networks / specifications example snippets
use Infinite\Specification\ORM as Spec;
$repository = $managerRegistry->getRepository('Entity\User');
// Retrieve any enabled users, ordered by username
$enabledUsersSpec = new Spec\Sort(array('username' => 'ASC'), new Spec\AndX(array(
new Spec\Equals('enabled', 1)
));
$enabledUsers = $repository->match($enabledUsersSpec);
// Count enabled users
$countEnabledUsersSpec = new Spec\SingleScalar(new Spec\Count(new Spec\Equals('enabled', 1)));
$enabledUsersCount = $repository->matchOne($countEnabledUsersSpec);