我在php中对PDO的分页存在问题 这是我的代码:
//pagination
if (isset($this->request->get['page'])) {
$page = intval($this->request->get['page']);
}
else {
$page = 1;
}
$itemsPerPage = 30;
$start = $itemsPerPage * ($page - 1);
//Dims92 products
$sql = 'SELECT * FROM oc_crawled_products WHERE store = ? ORDER BY id DESC LIMIT ?, ?';
$query = $this->db->prepare($sql);
$query->execute(["dims92", $start, $itemsPerPage]);
$this->data['dimsProducts'] = $query->fetchAll(PDO::FETCH_ASSOC);
我已经运行了查询SELECT * FROM oc_crawled_products WHERE store = "dims92" ORDER BY id DESC LIMIT 0 , 30
,但它运行正常。但是,当我使用php pdo代码尝试它时,它返回array
,其大小为0
,我找不到错误。