I am new to symfony2 and doctrine. I need to know how to get the complete list from a table using a doctrine command. getDoctrine()->getManager()->getRepository('bundeName')->findOneBy() gets only one value based on a criteria. Hope I'm making sense. Please help. Thank you.
1条回答 默认 最新
- doutian4046 2013-11-17 05:15关注
Try something like:
$repositorySites = $this->getDoctrine()->getRepository('SomeBundle:Sites'); $sites = $repositorySites->findAll();
This might help to filter (put in the class repo):
class SitesRepository extends EntityRepository { public function findByNot($field, $value) { $qb = $this->createQueryBuilder('a'); $qb->where($qb->expr()->not($qb->expr()->eq('a.'.$field, '?1'))); $qb->setParameter(1, $value); return $qb->getQuery() ->getResult(); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报