You are here

function hook_query_alter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Database/database.api.php \hook_query_alter()

Perform alterations to a structured query.

Structured (aka dynamic) queries that have tags associated may be altered by any module before the query is executed.

Parameters

$query: A Query object describing the composite parts of a SQL query.

See also

hook_query_TAG_alter()

node_query_node_access_alter()

AlterableInterface

SelectInterface

Related topics

2 functions implement hook_query_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

database_test_query_alter in core/modules/system/tests/modules/database_test/database_test.module
Implements hook_query_alter().
views_test_data_views_query_alter in core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
Implements hook_views_query_alter().
1 invocation of hook_query_alter()
DefaultSelection::reAlterQuery in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
Helper method: Passes a query to the alteration system again.

File

core/lib/Drupal/Core/Database/database.api.php, line 403
Hooks related to the Database system and the Schema API.

Code

function hook_query_alter(Drupal\Core\Database\Query\AlterableInterface $query) {
  if ($query
    ->hasTag('micro_limit')) {
    $query
      ->range(0, 2);
  }
}