> even if there is no userid by this name You're searching u.userid _and_ u.name, so you're sure the search-string isn't in u.userid _and_ isn't in u.name?
-- Jasper N. Brouwer (@jaspernbrouwer) On 24 Jan 2014, at 14:25, Jasper N. Brouwer <[email protected]> wrote: > Start by _not_ putting parameters directly into the query, but do it like > this: > > $q = $this->em->createQuery('SELECT u FROM user u WHERE u.userid LIKE ? OR > u.name LIKE ? ORDER BY u.userid'); > $q->setParameter(1, '%' . $username . '%'); > $q->setParameter(2, '%' . $username . '%'); > > or using named parameters: > > $q = $this->em->createQuery('SELECT u FROM user u WHERE u.userid LIKE > :userid OR u.name LIKE :name ORDER BY u.userid'); > $q->setParameter('userid', '%' . $username . '%'); > $q->setParameter('name', '%' . $username . '%'); > > > On 24 Jan 2014, at 14:20, vipul narain Agarwal <[email protected]> > wrote: > >> hi >> I am using following query to retrieve users using like >> >> $userQuery = $this->em->createQuery("SELECT u FROM user u WHERE >> u.userid LIKE '%.$username.%' OR u.name LIKE '%.$username.%' ORDER BY >> u.userid"); >> $userQuery->setParameter(1, '%' . $username . '%'); >> $userQuery->setParameter(2, '%' . $username . '%'); >> $userQuery->setMaxResults($usersMaxResult); >> $userData = $userQuery->getResult(); >> >> now when I am giving t__ as search criteria even if there is no userid by >> this name it is returning more than 30 results.. >> can any one explain what is wrong in it ? >> >> >> thanks in advance. > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/groups/opt_out.
