我想制作一个带限制的fetchAll()?你知道symfony2的实体经理是否有可能?
我当前的代码(全部获取,无限制):
$repository = $this->getDoctrine()->getRepository('MyBundle:Download'); $product = $repository->findAll();
谢谢大家.最好的祝福,
编辑:
$em = $this->getDoctrine()->getRepository('MyBundle:Download'); $ouput = $em->findBy(array(), array('id' => 'DESC'),5);
返回最后5行.
谢谢大家.
检查源代码通常很有启发性.
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); }