当我运行此查询时,它运行正常,没有错误。除此之外,它不会更新查询。
我已检查以确保我的表格行中存在$createdForm_id
,$document_id
中有值,$time_saved
中有值。
有人可以帮助我看看我在这里做错了吗?
//new database
$opt = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
try { $dbh_forms = new PDO("mysql:host=localhost;dbname=website_data", "root", "123", $opt); }
catch(PDOException $e) { echo $e->getMessage(); }
$update_data = $dbh_forms->prepare("UPDATE form_data SET document_id = :document_id AND time_saved = :time_saved WHERE id = :id");
$update_data->execute(array(':document_id' => $document_id, ':time_saved' => $time, ':id' => $createdForm_id));
答案 0 :(得分:-1)
你有'和'在您的查询中不属于那里。改变这个:
$update_data = $dbh_forms->prepare("UPDATE form_data SET document_id = :document_id AND time_saved = :time_saved WHERE id = :id");
通过删除和添加逗号来实现此目的:
$update_data = $dbh_forms->prepare("UPDATE form_data SET document_id = :document_id, time_saved = :time_saved WHERE id = :id");