有人可以指导我使用Zend db select编写如下的查询:
SELECT `tbl_md_users`.* FROM `tbl_md_users` WHERE user_type <> 'TYPE1') AND (first_name LIKE '%tom%' OR last_name LIKE '%tom%' OR user_name LIKE '%tom%')
如果你想
原文链接:https://www.f2er.com/php/240228.htmlSELECT `tbl_md_users`.* FROM `tbl_md_users` WHERE user_type <> 'TYPE1') AND (first_name LIKE '%tom%' OR first_name LIKE '%dick%' OR first_name LIKE '%harry%')
那么第一个答案是行不通的
我改用了Zend_Db_Expr
$likeTom = new Zend_Db_Expr("first_name LIKE '%tom%'"); $likeDick = new Zend_Db_Expr("first_name LIKE '%dick%'"); $likeHarry = new Zend_Db_Expr("first_name LIKE '%harry%'"); $query = $database->select () ->from ('tbl_md_users') ->where ('user_type <> ?','TYPE1') ->where ("{$likeTom} OR {$likeDick} OR {$likeHarry}");