I am trying to develop a simple module in Drupal 7. I want to return a table with some data in a function, which i am able to achieve. I am stuck in the pager part though.
pager_default_initialize($total, 10); $html .= theme('pager', array('quantity',$total));
and I can see the pager below my list, also I have 21 records for now and it shows << < 1 2 3 > >> which means it calculating 10 records each.
But my issue here is I can see all the 21 records at once regardless of whichever page I go to. I suppose I have goofed up my page_query.
When I tried using
$query->limit(10) it gives error Fatal error:
Call to undefined method SelectQuery::limit() in C:\xampp\htdocs...............
If I comment
$query->limit, there's no error but it does not work completely.
This is my query
$query = db_select('profile'); $query->fields('profile', array('id', 'name', 'store_name', 'company', 'city', 'email', 'phone')); $query->orderBy('id', 'DESC'); $query->extend('PagerDefault')->limit(10); //$query->limit(10); $results = $query->execute();
Thanks in advance! :)