0

I've got a problem with pagination with PDO in php here's my code:

//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);

I have runned the query SELECT * FROM oc_crawled_products WHERE store = "dims92" ORDER BY id DESC LIMIT 0 , 30 and it's working fine. But when I try it with the php pdo code it returns an array with size of 0 and I can't find the mistake.

Angel Miladinov
  • 1,596
  • 4
  • 20
  • 43

0 Answers0