關於使用PDO查詢MySQL資料庫問題

edited 十二月 2017 in 資料庫
大家好,
我關於使用PDO查詢發生的問題:
// SQL查詢的語句是這樣:
$sql = 'SELECT DISTINCT * FROM product INNER JOIN category ON product.series = category.prefix WHERE product.language = :language ORDER BY category.no DESC LIMIT :page, 10';

// 使用PDO塞入的對應參數是這樣
$param = [ ':language' => 'TW', ':page' => '5' ]

$result = $this->conn->prepare($sql);
$exec   = $result->execute($param);

錯誤訊息為 SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''5', 3' at line 1

不過當我把$sql的:page 替換 0, 並拿掉$param的:page參數後,
卻是可以跑的,
發生這個問題的原因要怎麼解決呢?
標籤:

評論

Sign In or Register to comment.