Get total items count on query with limit

Public

</> CopyGet raw version
php
  1. $query = db_select('node', 'n');
  2. $query->fields('n', array('nid', 'title'));
  3. $query->condition('status', 0, '>');
  4. // some code...
  5. $query = $query->extend('PagerDefault');
  6. $total_items = $query->getCountQuery()->execute()->fetchField();
  7. $query->limit(10);
  8. $result = $query->execute();

Comments

drupby's picture

print  $total_items; // 11