function 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

1 function implements 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 drupal/core/modules/system/tests/modules/database_test/database_test.module
Implements hook_query_alter().

File

drupal/core/modules/system/system.api.php, line 2673
Hooks provided by Drupal core and the System module.

Code

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