Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.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 1.3查找CONCAT多个字段下一个小时记录的条件_Php_Mysql_Sql_Cakephp 1.3_Concat - Fatal编程技术网

CakePHP 1.3查找CONCAT多个字段下一个小时记录的条件

CakePHP 1.3查找CONCAT多个字段下一个小时记录的条件,php,mysql,sql,cakephp-1.3,concat,Php,Mysql,Sql,Cakephp 1.3,Concat,下面是我的查找条件,用于获取与“DATE_ADD(NOW(),INTERVAL 1 HOUR)”匹配的记录, “CONCAT(`showdate`、'''hours`、':'、'minutes`、':00')>=”=>“NOW()”); 如果在PHPMyAdmin-SQL提示符下运行相同的查询,其工作如下: SELECT * FROM `showtimes` WHERE CONCAT( `showdate` , ' ', `hours` , ':', `minutes` , ':00' ) &

下面是我的查找条件,用于获取与“DATE_ADD(NOW(),INTERVAL 1 HOUR)”匹配的记录, “CONCAT(`showdate`、'''hours`、':'、'minutes`、':00')>=”=>“NOW()”); 如果在PHPMyAdmin-SQL提示符下运行相同的查询,其工作如下:

SELECT * FROM `showtimes` WHERE CONCAT( `showdate` , ' ', `hours` , ':', `minutes` , ':00' ) < DATE_ADD( NOW( ) , INTERVAL 1 HOUR ) AND CONCAT( `showdate` , ' ', `hours` , ':', `minutes` , ':00' ) >= NOW( ) LIMIT 0 , 30
从'showtimes'中选择*,其中CONCAT('showtate','hours','hours','minutes','minutes',':00')=NOW()限制0,30
上面的MySQL查询运行良好,但当我检查CakePHP Find时,它不起作用

以下是相同的组合:

$conditions = array(
    "CONCAT(`showdate`,' ',`hours`,':',`minutes`,':00') <" => "DATE_ADD(NOW(), INTERVAL 1 HOUR)",
    "CONCAT(`showdate`,' ',`hours`,':',`minutes`,':00') >=" => "NOW()",
    );

pr($conditions);
$this->Showtime->recursive = -1;
$areas = $this->Showtime->find('all',
            array(
                    'conditions' => $conditions,
                    'limit' => $limit,
                    'offset' => $offset,
                    'group' => 'Showtime.id',
                )
            );

pr($areas);
$conditions=array(
“CONCAT(`showdate`、'''hours`、':'、`minutes`、':00')=”=>“NOW()”,
);
公共关系(条件);
$this->Showtime->recursive=-1;
$areas=$this->Showtime->find('all'),
排列(
“条件”=>$conditions,
“限额”=>$limit,
“偏移量”=>$offset,
'组'=>'Showtime.id',
)
);
公共关系(领域);

任何帮助或想法都将不胜感激。

以下是我发现适合我的条件:

$conditions = array("CONCAT(`hours`,':',`minutes`) <=" => date('H:i', strtotime('+1 hour')), "CONCAT(`hours`,':',`minutes`) >=" => date('H:i'));
$conditions=array(“CONCAT(`hours`,':',`minutes`=”=>date(`H:i'));
希望对社区成员有所帮助

建议总是受欢迎的。

“创新”解决方案-为此,您应该在数据库中使用日期函数,而不是进行字符串比较
$conditions = array("CONCAT(`hours`,':',`minutes`) <=" => date('H:i', strtotime('+1 hour')), "CONCAT(`hours`,':',`minutes`) >=" => date('H:i'));