今天我試圖做幾個查詢時得到了一個不尋常的響應,這裏是錯誤輸出。綁定參數時出現SQLState錯誤
[17-Feb-2014 12:37:24 America/Denver] PHP Warning: PDOStatement::execute():
SQLSTATE[42000]: Syntax error or access violation: 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 'key = 'AH3D'' at line 1 in file on line 28
這裏是我使用的代碼,這是我怎麼總是做了。
public function get($key = null) {
$get = $this->conn->prepare("SELECT url FROM urls WHERE key = :get");
$get->execute(array(':get' => $key));
return $get->fetch();
}
我如何調用函數。
echo $tiny->get($_GET['key']);
可能重複一個mysql保留關鍵字如在MySQL]表或列名(http://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved-word-as-a-table-or-column-name-在MySQL的) –