首先,您需要创建 dbtable 模型:
class Application_Model_DbTable_Mfaq extends Zend_Db_Table_Abstract
{
protected $_name = 'm_faq';
}
然后按如下方式使用它:
$table = new Application_Model_DbTable_Mfaq();
$select = $table->getAdapter()->select()
->from(array('mfaq'=>$table->info(Zend_Db_Table::NAME)))
->where("( mfaq.delete_flg <> 'D'")
->orWhere("mfaq.delete_flg IS NULL )")
->where("( mfaq.title like ?", "%$title%")
->orWhere("mfaq.title like ? ", "%$title%")
->where(" mfaq.title like ?", "%$title%")
->orWhere("mfaq.title like ? )", "%$title%")
->order("create_date DESC");
// echo $select; // shows your sql
$results = $select->query()->fetchAll();
我希望,您考虑到 AND 比 OR 具有更高的优先级。