使用 Zend Db 进行多重过滤查询
我想使用 PHP 和 Zend Db 创建价格和类别过滤器。按价格或类别独立过滤时工作完美
如何使用 Zend DB 生成以下查询
SELECT * FROM `products` WHERE
(
(price >= '1000') AND (price <= '1500 ')
OR
(price >= '1500') AND (price <= '2000 ')
)
AND (category_id = '2')
尝试如下,
$this->where('price > ?', '1000')->where('price < ?', '1500');
$this->orwhere('price > ?', '1500')->where('price < ?', '2000');
$this->where('category > ?', '2');
但它生成,
SELECT * FROM `products` WHERE
(price >= '1000') AND (price <= '1500 ')
OR
(price >= '1500') AND (price <= '2000 ')
AND (category_id = '2')
有什么想法吗?
I would like to create a price and category filter using PHP and Zend Db. Works perfectly when filter independently by price or category
How to generate following query using Zend DB
SELECT * FROM `products` WHERE
(
(price >= '1000') AND (price <= '1500 ')
OR
(price >= '1500') AND (price <= '2000 ')
)
AND (category_id = '2')
Tried as follows,
$this->where('price > ?', '1000')->where('price < ?', '1500');
$this->orwhere('price > ?', '1500')->where('price < ?', '2000');
$this->where('category > ?', '2');
but it generates,
SELECT * FROM `products` WHERE
(price >= '1000') AND (price <= '1500 ')
OR
(price >= '1500') AND (price <= '2000 ')
AND (category_id = '2')
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)