这是我的选择功能:
public function search($for) {
$q = $this->select()->from($this->_name, array('id', 'title', 'content'))
->where('title LIKE ?', "%$for%")
->orWhere('content LIKE ?', "%$for%")
->orWhere('keywords LIKE ?', "%$for%")
->where('is_visible = ?', 0)
->where('category = ?', 7);
return $this->fetchAll($q);
}
但是为什么如果is_visible = 1或类别与7选择和其他行不同?
答案 0 :(得分:2)
我怀疑AND / OR优先级没有被正确解释。试试这个:
$q = $this->select()->from($this->_name, array('id', 'title', 'content'))
->where("title LIKE '%$for%' OR content LIKE '%$for%' OR keywords LIKE '%$for%'")
->where('is_visible = ?', 0)
->where('category = ?', 7);