Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FIND_IN_SET in doctrine 2 with DoctrineExtensions

here is my query

 $sql = 'SELECT users.userId as userId
      FROM App\UserProjects up
      LEFT JOIN up.user users 
      WHERE up.project = :project AND FIND_IN_SET(:comp, up.company)';
 $query = $this->getEntityManager()->createQuery($sql);
 $query->setParameter('project', 3);
$query->setParameter('comp', 4);
$results = $query->getResult();

But this gives me the error

[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string.

What am i doing wrong? Is there a work around? and the field i am searching in has comma seperated values, if FIND_IN_SET is not working, is there any other way i can do the same query?

and i am using this extension https://github.com/beberlei/DoctrineExtensions

like image 443
Waqar Haider Avatar asked Oct 29 '22 19:10

Waqar Haider


1 Answers

FIND_IN_SET give you the index of the searched element. You have to compare it to something:

FIND_IN_SET(:comp, up.company) != 0

You should use IN instead, it doesn't need any extension

AND :comp IN up.company
like image 161
goto Avatar answered Nov 13 '22 20:11

goto