Zend 框架数据库:OR 代替 AND 运算符 [英] Zend-framework DB: OR instead of AND operator

查看:22
本文介绍了Zend 框架数据库:OR 代替 AND 运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这样的zend查询:

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)

如果我有几个 AND 句子,zend 通过 AND 运算符连接它.如何将其与 OR 运算符连接?因为我需要:

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%')...

您的帮助将不胜感激.

推荐答案

$this->_table->select()->orWhere($condition);

要构建更复杂的查询(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.

这篇关于Zend 框架数据库:OR 代替 AND 运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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