How to limit size of result set in doctrine 2?

In Doctrine 2.1 method EntityRepository#findBy() now accepts additional parameters for ordering, limit and offset.

Documentation: Working with objects – Querying by simple conditions

Example:

 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)

usage:

$myLimit = 30;
$myOffset = 20;

$product = $repository->findBy(
    array('name' => 'foo'),
    array('price' => 'ASC'),
    $myLimit,
    $myOffset
);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)