我有以下几行:
$sql = "INSERT INTO news (title, content) VALUES :title, :content";
$pre = $this->prepare($sql);
$pre->bindValue(":title", "xxx");
$pre->bindValue(":content", "yyy");
$pre->execute();
我没有收到错误,但是查询也没有执行(我检查了查询日志)。
我拼命尝试了以下更改:
$t="xxx" and $pre->bindValue(":title", $t); (the same also for y)
$sql = "INSERT INTO `news` (`title`, `content`) VALUES :title, :content";
$sql = "INSERT INTO `news` (`title`, `content`) VALUES ':title', ':content'";
没有什么变化。有趣的是,我没有回应,没有警告,没有错误,只是一无所有。但是查询没有执行。
我发现了类似的帖子,但没有一个解决了我的问题。
(关于$this
...代码位于从PDO类扩展的类中。)
尝试: "INSERT INTO news (title, content) VALUES (:title, :content)";
您必须用括号将插入值括起来。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句