$pageMin = (($page * 10)-10);
$reponse = $bdd->prepare('SELECT pseudo, message FROM minichat ORDER BY id DESC LIMIT ?, 10'); $reponse->execute(array($pageMin));
似乎占位符不适用于LIMIT …
当我将pageMin连接起来时,例如:
$reponse = $bdd->query('SELECT pseudo, message FROM minichat ORDER BY id DESC LIMIT' . $pageMin . ', 10');
甚至
$reponse = $bdd->prepare('SELECT pseudo, message FROM minichat ORDER BY id DESC LIMIT' . $pageMin . ', 10'); $reponse->execute(array());
使用占位符,它不会返回任何结果,为什么?
谢谢你的帮忙。
当您将参数数组传递给execute它们时,它们将被视为字符串,并且limit是一个int值。只需将bindValue与int类型一起使用即可。
execute
$reponse->bindValue(1, $pageMin, PDO::PARAM_INT);