hook_query_alter

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 hook_query_alter(QueryAlterableInterface $query)

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()

QueryAlterableInterface

SelectQueryInterface

Related topics

Code

modules/system/system.api.php, line 3015

<?php
function hook_query_alter(QueryAlterableInterface $query) {
  if ($query->hasTag('micro_limit')) {
    $query->range(0, 2);
  }
}
?>