gpt4 book ai didi

php - Laravel 5 Sql 异常,但 SQL 运行正常?

转载 作者:行者123 更新时间:2023-11-29 22:19:15 25 4
gpt4 key购买 nike

谁能解释一下为什么我会遇到这个异常:

QueryException in Connection.php line 624:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? ? and ? ? ?' at line 1 (SQL: select * from `recipients` where firstname != 'Test' and firstname = 'Jodie')

当它声明的 SQL 在控制台中工作正常时?准备之前的查询是:

select * from `recipients` where ? ? ? and ? ? ?

我显然在做一些愚蠢的事情,但我完全被难住了,因为它一点也不复杂......

最佳答案

正如 Ofir Baruch 指出的那样,我无法像以前那样绑定(bind)所有内容(字段、条件运算符和值)。此后,我将准备好的语句替换为仅绑定(bind)值,并且它正在工作。

然而奇怪的是,从最初的异常来看,最终创建的 SQL 是完美的。只是,无法使用。

关于php - Laravel 5 Sql 异常,但 SQL 运行正常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30909939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com