有这样的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%')...
您的帮助将不胜感激.
$this->_table->select()->orWhere($condition);
要构建更复杂的查询(例如子条件),您可能必须使用$this-> table-> getAdapter() – > quoteInto()并手动写入SELECT.