Questions tagged «bindvalue»


10
如何在LIMIT子句中应用bindValue方法?
这是我的代码的快照: $fetchPictures = $PDO->prepare("SELECT * FROM pictures WHERE album = :albumId ORDER BY id ASC LIMIT :skip, :max"); $fetchPictures->bindValue(':albumId', $_GET['albumid'], PDO::PARAM_INT); if(isset($_GET['skip'])) { $fetchPictures->bindValue(':skip', trim($_GET['skip']), PDO::PARAM_INT); } else { $fetchPictures->bindValue(':skip', 0, PDO::PARAM_INT); } $fetchPictures->bindValue(':max', $max, PDO::PARAM_INT); $fetchPictures->execute() or die(print_r($fetchPictures->errorInfo())); $pictures = $fetchPictures->fetchAll(PDO::FETCH_ASSOC); 我懂了 您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册,以在第1行的“ 15”,“ 15”附近使用正确的语法 似乎PDO会将单引号添加到SQL代码的LIMIT部分的变量中。我查了一下,发现这个与我相关的错误:http : //bugs.php.net/bug.php?id=44639 那是我在看的吗?自2008年4月以来,此错误已被打开!同时,我们应该做什么? …
117 php  mysql  sql  pdo  bindvalue 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.