How to do a LIKE database query in Symfony2
Working example from my Symfony2 project:
$qb = $this->createQueryBuilder('u');$qb->where( $qb->expr()->like('u.username', ':user') ) ->setParameter('user','%Andre%') ->getQuery() ->getResult();
You should dump the created query for easier debugging.
I can only suggest you also try the querybuilder:
$qb = $em->createQueryBuilder();$result = $qb->select('n')->from('Acme\NodeBundle\Entity\Node', 'n') ->where( $qb->expr()->like('n.title', $qb->expr()->literal('%' . $searchterm . '%')) ) ->getQuery() ->getResult();
I think this option also helps:
$qb = $this->createQueryBuilder('u');$qb->where('u.username like :user') ->setParameter('user','%hereIsYourName%') ->getQuery() ->getResult();