This package is abandoned and no longer maintained. No replacement package was suggested.

dev-master 2014-05-07 01:37 UTC


Build Status Scrutinizer Code Quality Code Coverage


Example Usage

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());

        // Finally, apply limit, offset, order, and execute the select query
        QueryExpressionVisitor::apply($select, $criteria);

        return $this->tableGateway->selectWith($select);
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.