Zend 框架复杂 Where 语句 [英] Zend Framework Complex Where Statement
本文介绍了Zend 框架复杂 Where 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此方法作为官方示例发布
This method is published as offical example
->where("price <$minimumPrice OR price > $maximumPrice")这种方法安全吗?
->where("price < $minimumPrice OR price > $maximumPrice") is such method safe?
想把它写成->where("price OR price > ?", $minimumPrice, $maximumPrice)有没有可能?
want to write it as ->where("price < ? OR price > ?", $minimumPrice, $maximumPrice) are there any poissibility?
我不能将它分成 2 个 where 语句,因为计划编写查询-> where("1 或 2")->where("3 OR 4")
and I can't split it into 2 where statements because plan to write query ->where("1 OR 2") ->where("3 OR 4")
推荐答案
如果我有复杂的 WHERE
子句,我会使用数据库适配器的 ->quoteInto()
方法喜欢:
If I have complex WHERE
clauses I use the db adapters' ->quoteInto()
method like:
$where = '('
. $dbAdapter->quoteInto('price1 < ?', $price1)
. ' OR '
. $dbAdapter->quoteInto('price1 > ?', $price1)
. ')'
. ' AND '
. '('
. $dbAdapter->quoteInto('price2 < ?', $price2)
. ' OR '
. $dbAdapter->quoteInto('price2 > ?', $price2)
. ')'
;
$select->where($where);
这篇关于Zend 框架复杂 Where 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文