0
votes

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

1 Answers

1
votes

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