我在网上搜索,找不到能给我看的一个很好的实例.我的问题基本是这样的:
如何转换:
SELECT * FROM table WHERE((a = 1 AND b = 2)OR(c = 3 OR c = 4))AND d = 5;
到Zend类似的语法:
$这
– > select()的
– >从(; ”.$这 – > _schema $这 – > _name)
– > where(‘a =?’,’1′);
那怎么办呢?
提前多谢.
我也有类似的问题.请参阅这里的代码示例:
Grouping WHERE clauses with Zend_Db_Table_Abstract
原文链接:https://www.f2er.com/php/131526.html所以你最终会得到如下的东西:
$db = $this->getAdapter(); $this->select() ->where('(' . $db->quoteInto('a = ?',1) . ' AND ' . $db->quoteInto('b = ?',2) . ') OR (' . $db->quoteInto('c = ?',3) . ' OR ' . $db->quoteInto('c = ?',4) . ')') ->where('d = ?',5);
哪个会给你:
SELECT `table_name`.* FROM `table_name` WHERE ((a = 1 AND b = 2) OR (c = 3 OR c = 4)) AND (d = 5)