Hi i am trying to use pagination with query builder but it is not working.
Here is my Controller code
$category_prods = Product::model()->getCategoryProducts($categoryid, $categoryname);
$totalrecords = count($category_prods);
$criteria = new CDbCriteria;
$pages = new CPagination($totalrecords);
$pages->pageSize = 8;
$pages->applyLimit($criteria);
$data['products_data'] = $category_prods;
//passing data to view
$this->render('index', array(
'data' => $data,
//'posts' => $posts,
'pages' => $pages
));
HERE IS my View Code
foreach($data['products_data'] as $product):
echo "Title:".$product['title']."<br>Product ID:".$product['id']."<br><br>";
endforeach;
$this->widget('CLinkPager', array(
'pages' => $pages,
)) ;
The out is: all records are displaying simultaneously And the pager is also displaying. please help me. i dont know what wrong with it.