$prepared = $db->prepare("
SET @content = ?;
CALL add_interest_if_not_exists( @content );
SET @iid = (SELECT interests_id
FROM interests
WHERE content = @content);
REPLACE INTO profile_interests (user_id, interests_id, likes)
VALUES (
?,
@iid,
?
)
");
echo $db->error;
错误是:
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 'CALL add_interest_if_not_exists( @content ); SET @iid = (SELECT i' at line 3
该查询使用 MySQL 工作台(硬编码值)进行工作。为什么不在我准备好的声明中......
最佳答案
这不是单个查询,而是一组查询。
因此,您必须一一运行它们,每个都使用单独的 query()
或 prepare()/execute()
调用。
关于php - MySQLi 准备好的语句未采用调用过程的有效查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36374226/