嘗試使用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)
但這不起作用.任何的想法?