function hook_query_alter

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

File

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

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_query_alter/7.x