Zend-framework DB:OR 代替 AND 运算符
有这样的 zend 查询:
$select = $this->_table
->select()
->where('title LIKE ?', '%'.$searchWord.'%')
->where('description LIKE ?', '%'.$searchWord.'%')
->where('verified=1 AND activated=1');
换句话说,它看起来像:
SELECT `some_table`.* FROM `some_table` WHERE (title LIKE '%nice house%') AND (description LIKE '%nice house%') AND (verified=1 AND activated=1)
如果我有几个 AND 句子,zend 通过 AND 运算符连接它。如何将它与 OR 运算符连接?因为我需要:
...(title LIKE '%nice house%') OR (description LIKE '%nice house%')...
您的帮助将不胜感激。
have such zend query:
$select = $this->_table
->select()
->where('title LIKE ?', '%'.$searchWord.'%')
->where('description LIKE ?', '%'.$searchWord.'%')
->where('verified=1 AND activated=1');
In other words it looks like:
SELECT `some_table`.* FROM `some_table` WHERE (title LIKE '%nice house%') AND (description LIKE '%nice house%') AND (verified=1 AND activated=1)
If I have couple AND sentences, zend connect it through AND operator. How can I connect it with OR operator ? Cause I need:
...(title LIKE '%nice house%') OR (description LIKE '%nice house%')...
Your help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要构建更复杂的查询(ig 子条件),您可能必须使用
$this->table->getAdapter()->quoteInto()
并手动编写 SELECT。To build more complexe queries (i.g. sub-conditions) you might have to use
$this->table->getAdapter()->quoteInto()
and write your SELECT manually.这里的其他答案不起作用(不再?),当前的解决方案是在where子句中调用nest()和unnest():
The others answers here do not work (anymore?), the current solution is to call nest() and unnest() in the where clause:
我已经实现了你的 zend 查询
I have implemented your zend query