我有我的查询,该查询在MySQL中完美运行

SELECT * FROM accounts WHERE location_id=1 AND created_at>=*timestamp*


我在Zend中有一个Accounts表模型。我用了

$accounts->where(array('location_id' => 1))


当我尝试使用另一个where子句时

->where("created_at >= $timestamp")


Zend抛出此错误:

"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 7"


我也尝试过硬编码$timestamp变量,删除第一个where并仅使用第二个,甚至尝试将语法更改为

->where("created_at >= " . $timestamp)


他们都没有工作。有什么想法吗?

后期编辑

我想通了,似乎这是一个语法问题。这为我工作:

where("created_at >= '$timestamp'");

最佳答案

->where("start >= ?", $timestamp)


(在ZF1中)。另外,在您说的查询中效果很好,该列名为created_at

关于php - Zend查询大于或等于,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49881514/

10-14 19:27
查看更多