Doctrine2 Querybuilder bitwise and

I would like to use bitwise comparison in my Doctrine2 / Symfony2 QueryBuilder. I tried

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

and

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

but they both indicated the following error:

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

+5
source share
1 answer

You need to compare the result BIT_ANDwith something ... for example:

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

All Articles