Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 具有多个相似条件的搜索_Php_Sql_Cakephp - Fatal编程技术网

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'
));