我有这个 ActiveRecord 来生成查询,
$this->purchase_requisition_model
->where('deleted','1')
->likes('to',$sapfvalue,'both')
->likes('date',$sapfvalue,'both')
->likes('request_by',$sapfvalue,'both')
->likes('deliver_to',$sapfvalue,'both')
->likes('name',$sapfvalue,'both')
->likes('telephone',$sapfvalue,'both')
->likes('designation',$sapfvalue,'both')
->likes('budget_status',$sapfvalue,'both')
->find_all();
上面的 ActiveRecord 将产生以下查询,
SELECT * FROM (`purchase_requisition`)
WHERE `deleted` = '1'
AND `to` LIKE '%fg%'
OR `date` LIKE '%fg%'
OR `request_by` LIKE '%fg%'
OR `deliver_to` LIKE '%fg%'
OR `name` LIKE '%fg%'
OR `telephone` LIKE '%fg%'
OR `designation` LIKE '%fg%'
OR `budget_status` LIKE '%fg%'
但是如何使用 ActiveRecord 生成以下查询?
SELECT * FROM (`purchase_requisition`)
WHERE `deleted` = '1'
AND ( `to` LIKE '%fg%'
OR `date` LIKE '%fg%'
OR `request_by` LIKE '%fg%'
OR `deliver_to` LIKE '%fg%'
OR `name` LIKE '%fg%'
OR `telephone` LIKE '%fg%'
OR `designation` LIKE '%fg%'
OR `budget_status` LIKE '%fg%' )