(PHP) (SQL) INSERT INTO 的语法有什么问题?
(PHP) (SQL) What is wrong with the syntax of INSERT INTO?
[1064: 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 ')' at line 1] in EXECUTE("INSERT INTO mailer_recipients (status,send_result_id) VALUES (,)")
public function saveData($status, $resultId)
{
global $dbwriter;
// Update send result, send result ID, status
$sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['status'] . "='$status' WHERE " . $this->recipientDbColumn['id'] . '=' . $this->getId();
$sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['result_id'] . "='$resultId' WHERE " . $this->recipientDbColumn['id'] . '=' . $this->getId();
$sql = 'INSERT INTO ' . $this->recipientDbTable;
$sql .= ' (' . $this->recipientDbColumn['status'] . ',' . $this->recipientDbColumn['result_id'] . ')';
$sql .= ' VALUES ' . '(' . $status . ',' . $resultId . ')';
$result = $dbwriter->execute($sql);
}
更新很好。不知道是什么问题。
阅读您的错误消息。您的 SQL 以 VALUES (,)
结尾,这是无效的语法。显然,$status
和 $resultId
是空的(''
、null
或其他计算为空字符串的值)。
[1064: 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 ')' at line 1] in EXECUTE("INSERT INTO mailer_recipients (status,send_result_id) VALUES (,)")
public function saveData($status, $resultId)
{
global $dbwriter;
// Update send result, send result ID, status
$sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['status'] . "='$status' WHERE " . $this->recipientDbColumn['id'] . '=' . $this->getId();
$sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['result_id'] . "='$resultId' WHERE " . $this->recipientDbColumn['id'] . '=' . $this->getId();
$sql = 'INSERT INTO ' . $this->recipientDbTable;
$sql .= ' (' . $this->recipientDbColumn['status'] . ',' . $this->recipientDbColumn['result_id'] . ')';
$sql .= ' VALUES ' . '(' . $status . ',' . $resultId . ')';
$result = $dbwriter->execute($sql);
}
更新很好。不知道是什么问题。
阅读您的错误消息。您的 SQL 以 VALUES (,)
结尾,这是无效的语法。显然,$status
和 $resultId
是空的(''
、null
或其他计算为空字符串的值)。