Php 使用PDO的已准备语句上的HY000常规错误

Php 使用PDO的已准备语句上的HY000常规错误,php,mysql,pdo,Php,Mysql,Pdo,为什么我总是在这个查询中得到HY000错误一般错误 SET @uid:=?; SET @uscore:=(SELECT `total_score` FROM `user` WHERE `user_id` = @uid LIMIT 1); SELECT `user_id`, `username`, `total_score` FROM `user` WHERE `total_score` > @uscore OR `user_id` = @uid OR `total_score` &l

为什么我总是在这个查询中得到HY000错误一般错误

SET  @uid:=?;
SET  @uscore:=(SELECT `total_score` FROM `user` WHERE `user_id` = @uid LIMIT 1);

SELECT `user_id`, `username`, `total_score` FROM `user`
WHERE `total_score` > @uscore
OR `user_id` = @uid
OR `total_score` < @uscore
ORDER BY `total_score` DESC
LIMIT 11

然而,在MySQL工作台上运行相同的查询时,只需替换?与11。连接到DBMS或其他东西时,我是否遗漏了什么?

您是否在相同的->准备$sql调用中执行这些set调用?不能在一个查询调用中发出多个语句。是否有解决方法?我唯一能想到的是在每次评估中重复SELECT total_score`FROM user WHERE user_id=@uid LIMIT 1`子查询,但我认为这不是很有效。分别运行它们。->查询集…;->查询集…;->查询选择。。。;变量是每个连接的,因此将在单独的查询调用之间保持不变。但是,我如何执行准备好的语句来绑定第一个集合中的值呢?谢谢!我工作得很有魅力!你能把这个写下来作为回答,这样我就可以结束这个问题了吗?
SELECT `user_id`, `username`, `total_score` FROM `user`
WHERE `total_score` > 5000
OR `user_id` = 11
OR `total_score` < 5000
ORDER BY `total_score` DESC
LIMIT 11