如何使用原则从Symfony2中的数据库表中获取值列表


How to get a list of values from a database table in Symfony2 using doctrine?

我是symfony2和教义的新手。我需要知道如何使用教义命令从表中获取完整列表。getDoctrine()->getManager()->getRepository('bundeName')->findOneBy() 根据条件仅获取一个值。希望我说得有道理。请帮忙。谢谢。

尝试类似操作:

$repositorySites = $this->getDoctrine()->getRepository('SomeBundle:Sites');
$sites           = $repositorySites->findAll();

这可能有助于过滤(放入类存储库中):

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