roave / roave-db-criteria
This package is abandoned and no longer maintained.
No replacement package was suggested.
dev-master
2014-05-07 01:37 UTC
Requires
- php: ~5.3, >=5.3.23
- doctrine/collections: ~1.2
- zendframework/zend-db: ~2.3
Requires (Dev)
- phpunit/phpunit: ~4.0.0
- squizlabs/php_codesniffer: ~2.0.0@DEV
This package is auto-updated.
Last update: 2022-11-12 21:19:29 UTC
README
v0.0.1
Example Usage
<?php use Roave\DbCriteria\QueryExpressionVisitor; use Doctrine\Common\Collections\Criteria; class ContactMapper { protected $visitor; protected $tableGateway; public function find(Criteria $citeria) { $select = $this->tableGateway->getSql()->select() // You can apply your own Zend\Db\Sql query conditions ->where(array('user_id' => $this->activeUser->id)); // Then apply the criteria to the query $where = $this->visitor->dispatch($criteria->getWhereExpression()); $select->where($where); // Finally, apply limit, offset, order, and execute the select query QueryExpressionVisitor::apply($select, $criteria); return $this->tableGateway->selectWith($select); } }
<?php use Doctrine\Common\Collections\Criteria; $criteria = Criteria::create() ->where(Criteria::expr()->eq('first_name', 'Evan')) ->andWhere(Criteria::expr()->eq('last_name', 'Coury')); $contacts = $contactMapper->find($criteria);
In practice, you can create domain-specific criteria objects and plenty of other cool things.