SELECT *
FROM product_details
WHERE material_id LIKE '%4'
OR material_id LIKE '%5'
ORDER BY `product_details`.`material_id` ASC
LIMIT 0 , 30
我的条件就像
$conditions[] = array(
'OR' => array(
'LOWER(`Product`.`product_name`) LIKE' => '%'.$search_query.'%',
'LOWER(`ProductDetail`.`designer_id`) LIKE' => '%'.$get_designer_id.'%',
'LOWER(`Product`.`category_id`) LIKE' => '%'.$get_category_id.'%',
'LOWER(`ProductDetail`.`color_id`) LIKE' => $color_id,
'LOWER(`ProductDetail`.`material_id`) LIKE' => '%'.$meterial_id.'%',
'LOWER(`ProductDetail`.`product_code`) LIKE' => '%'.$search_query.'%',
//'LOWER(`ProductDetail`.`gbp_price`) LIKE' => '%'.$search_query.'%',
// 'LOWER(`ProductDetail`.`euro_price`) LIKE' => '%'.$search_query.'%',
'LOWER(`ProductDetail`.`description`) LIKE' => '%'.$search_query.'%',
),
);
如何在cake php中编写此查询
答案 0 :(得分:1)
除了我之外,为什么你会LOWER()
id字段以及为什么它不在你的原始查询中。
但原始查询大致转换为CakePHP查找:
$this->ProductDetail->find('all', array(
'conditions' => array(
'OR' => array(
'material_id LIKE' => '%4',
'material_id LIKE' => '%5',
)
),
'order' => array('material_id' => 'ASC'),
'limit' => '0, 30'
));