Php 具有多个相似条件的搜索
我的情况是Php 具有多个相似条件的搜索,php,sql,cakephp,Php,Sql,Cakephp,我的情况是 SELECT * FROM product_details WHERE material_id LIKE '%4' OR material_id LIKE '%5' ORDER BY `product_details`.`material_id` ASC LIMIT 0 , 30 如何在cake php中编写此查询我无法理解为什么要降低id字段,为什么在原始查询中没有。 但原始查询大致转化为以下CakePHP发现: $conditions[] = array( '
SELECT *
FROM product_details
WHERE material_id LIKE '%4'
OR material_id LIKE '%5'
ORDER BY `product_details`.`material_id` ASC
LIMIT 0 , 30
如何在cake php中编写此查询我无法理解为什么要降低id字段,为什么在原始查询中没有。 但原始查询大致转化为以下CakePHP发现:
$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.'%',
),
);
'LOWERProductDetail.material_id如'=>'%.$material_id'%',更新您的问题,不要对其进行评论。。。我问的是PHP代码,不是SQLI,我不知道如何使用或…仍然没有编辑问题,而是使用注释…使用
$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'
));