我想创建一个带limit的fetchAll()。你知道有没有可能使用symfony2的实体管理器?
我当前的代码(Fetch all,无限制):
$repository = $this->getDoctrine()->getRepository('MyBundle:Download');
$product = $repository->findAll();谢谢大家。诚挚的问候,
编辑:
$em = $this->getDoctrine()->getRepository('MyBundle:Download');
$ouput = $em->findBy(array(), array('id' => 'DESC'),5);返回最后5行。
谢谢大家。
发布于 2014-02-01 22:41:18
检查源代码通常是有指导意义的。
Doctrine\ORM\EntityRepository
public function findAll()
{
return $this->findBy(array());
}
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
return $persister->loadAll($criteria, $orderBy, $limit, $offset);
}https://stackoverflow.com/questions/21499296
复制相似问题