function SqlBase::query
Same name in this branch
- 9 core/modules/migrate/src/Plugin/migrate/source/SqlBase.php \Drupal\migrate\Plugin\migrate\source\SqlBase::query()
Same name in other branches
- 8.9.x core/modules/views/src/Plugin/views/pager/SqlBase.php \Drupal\views\Plugin\views\pager\SqlBase::query()
- 8.9.x core/modules/migrate/src/Plugin/migrate/source/SqlBase.php \Drupal\migrate\Plugin\migrate\source\SqlBase::query()
- 10 core/modules/views/src/Plugin/views/pager/SqlBase.php \Drupal\views\Plugin\views\pager\SqlBase::query()
- 10 core/modules/migrate/src/Plugin/migrate/source/SqlBase.php \Drupal\migrate\Plugin\migrate\source\SqlBase::query()
- 11.x core/modules/views/src/Plugin/views/pager/SqlBase.php \Drupal\views\Plugin\views\pager\SqlBase::query()
- 11.x core/modules/migrate/src/Plugin/migrate/source/SqlBase.php \Drupal\migrate\Plugin\migrate\source\SqlBase::query()
Overrides PagerPluginBase::query
1 call to SqlBase::query()
- Mini::query in core/
modules/ views/ src/ Plugin/ views/ pager/ Mini.php - Modify the query for paging.
1 method overrides SqlBase::query()
- Mini::query in core/
modules/ views/ src/ Plugin/ views/ pager/ Mini.php - Modify the query for paging.
File
-
core/
modules/ views/ src/ Plugin/ views/ pager/ SqlBase.php, line 259
Class
- SqlBase
- A common base class for sql based pager.
Namespace
Drupal\views\Plugin\views\pagerCode
public function query() {
if ($this->itemsPerPageExposed()) {
$query = $this->view
->getRequest()->query;
$items_per_page = $query->get('items_per_page');
if ((int) $items_per_page > 0) {
$this->options['items_per_page'] = $items_per_page;
}
elseif ($items_per_page == 'All' && $this->options['expose']['items_per_page_options_all']) {
$this->options['items_per_page'] = 0;
}
}
if ($this->isOffsetExposed()) {
$query = $this->view
->getRequest()->query;
$offset = $query->get('offset');
if (isset($offset) && $offset >= 0) {
$this->options['offset'] = $offset;
}
}
$limit = $this->options['items_per_page'];
$offset = $this->current_page * $this->options['items_per_page'] + $this->options['offset'];
if (!empty($this->options['total_pages'])) {
if ($this->current_page >= $this->options['total_pages']) {
$limit = $this->options['items_per_page'];
$offset = $this->options['total_pages'] * $this->options['items_per_page'];
}
}
$this->view->query
->setLimit($limit);
$this->view->query
->setOffset($offset);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.