我使用 zend 1.12 来查询数据库以获得概览。现在我可以使用几个过滤器和一个搜索查询。这些都进入一个查询,如下所示:
SELECT `x`.`id`, `x`.`ref_id`, `x`.`start_date`, `x`.`regard`, `x`.`project_code`, `o`.`name` AS `contact`, `o`.`id` AS `contact_id`, `d`.`name` AS `department`, `c`.`name` AS `company`, `is`.`name` AS `status`, SUM(ip.price*ip.amount*(100-ip.discount)/100) AS `price_ex`, SUM(ip.price*ip.amount*(100-ip.discount)*(100+ip.tax)/10000)-IFNULL(p.payment,0) AS `price_open` FROM `invoice` AS `x`
LEFT JOIN `contact` AS `o` ON x.recipient_id=o.id
LEFT JOIN `department` AS `d` ON o.department_id=d.id
LEFT JOIN `company` AS `c` ON d.company_id=c.id
LEFT JOIN `invoice_status` AS `is` ON x.status=is.id
LEFT JOIN `invoice_part` AS `ip` ON x.id=ip.invoice_id
LEFT JOIN (SELECT SUM(amount) AS `payment`, `payment`.`invoice_id` FROM `payment` GROUP BY `invoice_id`) AS `p` ON x.id=p.invoice_id
WHERE (month(x.start_date) = '6') AND (year(x.start_date) = '2013') OR (LOWER(x.regard) LIKE '%test%') OR (LOWER(o.name) LIKE '%test%') OR (LOWER(c.name) LIKE '%test%') OR (LOWER(ref_id) LIKE '%test%') OR (LOWER(start_date) LIKE '%test%') GROUP BY `x`.`id` ORDER BY `x`.`updated_at` DESC LIMIT 50
现在添加了所有过滤器,AND
但是当我在列上搜索时,它被添加为或,但现在所有内容都找到了。我想要做的是[filter] AND [filter] AND ([search] or [search])
。( )
是否可以在我的 zend 查询中添加这些?