2013-04-06 17 views
5

Vorrei utilizzare un confronto bit a bit nel mio QueryBuilder Doctrine2/Symfony2. Ho provatoDoctrine2 Querybuilder bit a bit e

->andWhere('n.sharingenabled & 1') 

E

->andWhere('BIT_AND(n.sharingenabled, 1)') 

ma entrambi buttato il seguente errore

QueryException: [Syntax Error] line 0, col 327: Error: Expected =, <, <=, <>, >, >=, !=, got '&'

risposta

18

È necessario confrontare il risultato BIT_AND a qualcosa ... per esempio:

->andWhere('BIT_AND(n.sharingenabled, 1) > 0') 
+0

I ho provato '-> andWhere ('i.flags & 1 = 1')' e questo non ha funzionato neanche. Usando la tua soluzione ha funzionato per me !! – DanFromGermany