Я не могу вернуть $ limit и $ offset в моей модели в разбивке по страницам в Codeigniter. Это мой код, который отображает данные из категории базы данных, подкатегории и продуктов. мои таблицы: Main_Category, Category, Prosucts.
public function all_collection($id) {
$this->db->select( '*' );
$this->db->order_by( 'category.orderList', 'DESC' );
$this->db->where( 'statusCategory', 1 );
$this->db->where('category.category_id',$id);
$this->db->join('category_menu','category_menu.id=category.MainCategory_id','left');
//$this->db->where('category_menu.displayType',1);
$this->db->where('category.parent_id',0);
$query = $this->db->get( 'category');
$return=array();
foreach ($query->result() as $category)
{
$return[$category->category_id]=$category;
$return[$category->category_id]->subs = $this->getSubcategory($category->category_id); // Get the categories sub categories
}
return $return;
}
public function getSubcategory($parent_id) {
$this->db->select( '*' );
$this->db->order_by( 'category_id', 'DESC' );
$this->db->where('parent_id',$parent_id);
$this->db->where( 'category.statusCategory', 1 );
$data = $this->db->get( 'category' );
$products=$data->result();
$i=0;
foreach($products as $category){
$products[$i]->subss = $this->getProducts($category->category_id);
$i++;
}
return $products;
}
public function getProducts($cat_id){
$this->db->select('*');
$this->db->where('product.category_ids',$cat_id);
$this->db->where('product.p_deleted_at =', 'NULL');
$this->db->join('product_price','product_ids=product.product_id','left')->limit(1)->where('statusPrice',1)->order_by('price_id','DESC');
$this->db->join('product_image','improduct_ids=product.product_id','left')->limit(1)->where('statusProImage',1)->order_by('image_id','DESC');
$this->db->join('product_stock','product_stock.product_id=product.product_id','left')->limit(1)->where('statusStock',1)->order_by( 'stock_id', 'DESC' );
$this->db->join('brand','brand_id=product.brand_ids','left');
$query=$this->db->get('product');
return $query->result();
}