Doctrine2 Querybuilder按位和 [英] Doctrine2 Querybuilder bitwise and

查看:120
本文介绍了Doctrine2 Querybuilder按位和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Doctrine2 / Symfony2 QueryBuilder中使用一个比较的比较。
我试过

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

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

但是他们都抛出了以下错误


QueryException:[Syntax Error] line 0,col 327:Error:Expected =,<
&



解决方案

您需要将 BIT_AND 结果与某些东西进行比较,例如:

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


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 '&'

解决方案

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

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

这篇关于Doctrine2 Querybuilder按位和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆