Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.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/1/typo3/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 如何在TableGateway where子句中使用SQL函数?_Php_Mysql_Sql_Pdo_Zend Framework2 - Fatal编程技术网

Php 如何在TableGateway where子句中使用SQL函数?

Php 如何在TableGateway where子句中使用SQL函数?,php,mysql,sql,pdo,zend-framework2,Php,Mysql,Sql,Pdo,Zend Framework2,我试图在Zend-Framework2 TableGateway中使用SQLCURDATE(),但出现异常 未找到列:“where子句”中的1054未知列“CURDATE” 这是我的代码: $where_clause = "date between CURDATE() AND ADDDATE(CURDATE, INTERVAL 7 DAY)"; $resultSet = $this->tableGateway->select($where_clause); 有没有更好的方法来

我试图在Zend-Framework2 TableGateway中使用SQL
CURDATE()
,但出现异常

未找到列:“where子句”中的1054未知列“CURDATE”

这是我的代码:

$where_clause = "date between CURDATE() AND ADDDATE(CURDATE, INTERVAL 7 DAY)";   
$resultSet = $this->tableGateway->select($where_clause);

有没有更好的方法来创建带有where子句的SQL语句?

您是否需要在ADDDATE调用中使用
CURDATE()
,这样MySQL就知道它是函数调用而不是列了?@andrewsi确实是这样,现在它可以工作了;非常感谢。你能把它写下来作为答案,这样我就可以选择它作为解决方案了吗?