Example #1
0
 public function index($perpage = 12, $page = 1)
 {
     $registros = $this->count();
     $pagination = Pagination::pager($registros, $perpage, $page);
     $sql = "SELECT * FROM customers WHERE id IN (SELECT customer_id FROM orders LIMIT " . $pagination->offset . "," . $pagination->limit . ")";
     $data = $this->db->run($sql);
     return $data;
 }
Example #2
0
 public function findWithPhotos($pp, $page)
 {
     $registros = $this->count();
     $pagination = Pagination::pager($registros, $pp, $page);
     $sql = "SELECT * FROM products ORDER BY created DESC LIMIT " . $pagination->offset . ", " . $pagination->limit;
     $data = $this->db->run($sql);
     $products = array();
     foreach ($data as $data) {
         $sql = "SELECT * FROM photos WHERE product_id = " . $data['product_id'];
         $photos = $this->db->run($sql);
         $data['photos'] = $photos;
         $products[] = $data;
     }
     $pages = $pagination->num_pages;
     return $products;
 }