Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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
CakePHP不区分大小写的查找_Php_Cakephp - Fatal编程技术网

CakePHP不区分大小写的查找

CakePHP不区分大小写的查找,php,cakephp,Php,Cakephp,有没有办法在CakePHP中执行不区分大小写的查找?e、 g.是否可能出现以下情况 $record = $this->find( 'first', array( 'conditions' => array( 'name' => $name, 'ignore-case' => true ) ) ); 我正在使用CakePHP 1.3,如果这很重要的话是的,我知道它已经过时

有没有办法在CakePHP中执行不区分大小写的查找?e、 g.是否可能出现以下情况

$record = $this->find(
    'first', 
    array(
       'conditions' => array(
           'name' => $name,
           'ignore-case' => true
        )
    )
); 

我正在使用CakePHP 1.3,如果这很重要的话是的,我知道它已经过时了,但我还没有时间迁移它。

也许不是最好的方法,但有一种可能性是:

    $record = $this->find(
         'first', 
         array(
              'conditions' => array(
              'LOWER(Model.name)' => strtolower($name)
             )
         )
     ); 

将db collate更改为_cit,这实际上应该是IMO的默认值-对于大多数应用程序来说,使用区分大小写的表/字段是没有意义的。或者只使用上面注释中概述的正确排序=>修复问题的根源,而不是消除症状。