1
我有一組似乎無法工作的PDO語句。基本上我試圖更新1表中的「等待」值,然後選擇相同的行並將其插入到另一個表中。PDO查詢不起作用
$statement = $db->prepare("UPDATE waiting SET wait = :status WHERE id = :id");
$statement->bindValue(':status', 0);
$statement->bindParam(':id', $id);
$statement->execute();
$statement = $db->prepare("INSERT INTO approved (fname, lname, student_id, email, type) (SELECT fname, lname, student_id, email, type FROM waiting WHERE id = :id)");
$statement->bindParam(':id', $id);
$statement->execute();
我也試着設置$statement
爲null我做其他查詢之前,但沒有工作,要麼:
$statement = $db->prepare("UPDATE waiting SET wait = :status WHERE id = :id");
$statement->bindValue(':status', 0);
$statement->bindParam(':id', $id);
$statement->execute();
$statement = null;
$statement = $db->prepare("INSERT INTO approved (fname, lname, student_id, email, type) (SELECT fname, lname, student_id, email, type FROM waiting WHERE id = :id)");
$statement->bindParam(':id', $id);
$statement->execute();
爲什麼這是行不通的任何想法?
你是否收到任何錯誤消息? – Wabbitseason
定義「沒有工作」。兩個查詢都沒有正確執行?你是否收到'$ statement-> errorInfo()'的錯誤信息? –
您的[INSERT-Query(MySQL)](http://dev.mysql.com/doc/refman/5.1/en/insert.html)錯誤:INSERT INTO已批准(...)** VALUES ** (...)' – Saxoier