在我的PHP脚本失败后,我尝试了这个以及SQL的多个变体 - 它告诉我我的语法错误。MySQL语法错误 - 尝试更新行而不删除/创建新主键
INSERT INTO qarows (questions, answers) VALUES(test, test) WHERE id='735'
这是我的数据库结构:http://imgur.com/GEnwgvm
这是PHP脚本我开始:
function updateDatabase($compare){
$update = $this->dbh->prepare("
INSERT INTO qarows (
questions, answers, updateTimeUnicode, updateTimeNatural
) VALUES (
:questions, :answers, :updateTimeUnicode, :updateTimeNatural
) WHERE id=:id
");
$update->execute(array(
':questions' => $this->question,
':answers' => $this->answer,
':updateTimeUnicode' => $this->updateTimeUnicode,
':updateTimeNatural' => $this->updateTimeNatural,
':id' => $this->id
));
感谢您的帮助。
不能同时插入和地点。 – 2014-11-08 09:48:08
引用测试“测试”可以帮助以及从插入语句中删除哪些clausule。 – 2014-11-08 09:48:22
删除部分回答的问题对未来的访问者不利。 – Paul 2014-11-08 10:08:31