天天看点

mysql pdo limit_php – mysql LIMIT和PDO的问题

尝试使用PDO进行可怕的分页,但我找不到符合我情况的答案:

$pageVar = 10;

$startRowLimit = ($page * $pageVar) - $pageVar; // returns correct value

$articlesQuery = "SELECT

`ID`,`Title`,`Text`,`Poster`,`Date`,

( SELECT `ID` FROM users WHERE article.`Poster` = users.`Username` )

FROM article WHERE `Visible` = 1 ORDER BY `Date` DESC LIMIT ? , ? ";

$articles = $mysqli->selectAll($articlesQuery, array($startRowLimit, $pageVar));

这是selectAll函数:

public function selectAll($query, $params){

$this->sql = $this->dbh->prepare($query);

$this->sql->execute($params);

$result = $this->sql->fetchAll(PDO::FETCH_ASSOC);

return $result;

}

我怎样才能使它工作?我试过了

array((int) $startRowLimit, (int) $pageVar)

但这不起作用.任何的想法?