Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine2 Querybuilder bitwise and

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

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

And

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

but they both threw the following error

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

like image 713
Raymen Avatar asked Apr 06 '13 18:04

Raymen


1 Answers

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

->andWhere('BIT_AND(n.sharingenabled, 1) > 0')
like image 63
Manse Avatar answered Oct 31 '22 15:10

Manse