public function PagerDefault::execute

cis7 pager.inc public PagerDefault::execute()
cle7 pager.inc public PagerDefault::execute()
elmsmedia7 pager.inc public PagerDefault::execute()
icor7 pager.inc public PagerDefault::execute()
meedjum_blog7 pager.inc public PagerDefault::execute()
mooc7 pager.inc public PagerDefault::execute()

Override the execute method.

Before we run the query, we need to add pager-based range() instructions to it.

File

includes/pager.inc, line 59
Functions to aid in presenting database results as a set of pages.

Class

PagerDefault
Query extender for pager queries.

Code

public function execute() {

  // Add convenience tag to mark that this is an extended query. We have to
  // do this in the constructor to ensure that it is set before preExecute()
  // gets called.
  if (!$this->preExecute($this)) {
    return NULL;
  }

  // A NULL limit is the "kill switch" for pager queries.
  if (empty($this->limit)) {
    return;
  }
  $this->ensureElement();

  $total_items = $this->getCountQuery()->execute()->fetchField();
  $current_page = pager_default_initialize($total_items, $this->limit, $this->element);
  $this->range($current_page * $this->limit, $this->limit);

  // Now that we've added our pager-based range instructions, run the query normally.
  return $this->query->execute();
}