在我的PDO實現,我試圖SQL語句的限制子句中使用插入值:正確返回在SQL語句的limit子句中使用PDO插入值?
$sql = "SELECT * FROM table ORDER BY datetime DESC LIMIT :limit";
$params = array(":limit" => 5);
$query = $dbh->prepare($sql);
$query->execute($params);
$result = $query->fetchall(PDO::FETCH_ASSOC);
$params
和$query
,但$result
是空的。
在運行print_r($query->errorInfo);
,我得到如下:
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 ''5'' at line 1
如何使用PDO的插入值在此查詢?我做對了嗎?
你登錄查詢?什麼是實際的SQL是生成? – Wes 2011-06-03 01:57:58