function hook_query_alter
Same name in other branches
- 9 core/lib/Drupal/Core/Database/database.api.php \hook_query_alter()
- 8.9.x core/lib/Drupal/Core/Database/database.api.php \hook_query_alter()
- 10 core/lib/Drupal/Core/Database/database.api.php \hook_query_alter()
- 11.x 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
node_query_node_access_alter()
Related topics
6 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 modules/
simpletest/ tests/ database_test.module - Implements hook_query_alter().
- field_test_entity_query_alter in modules/
field/ tests/ field_test.module - Implements hook_entity_query_alter().
- field_test_query_store_global_test_query_alter in modules/
field/ tests/ field_test.module - Implements hook_query_TAG_alter() for tag 'store_global_test_query'.
- search_node_tags_query_alter in modules/
search/ tests/ search_node_tags.module - Implements hook_query_alter().
- taxonomy_entity_query_alter in modules/
taxonomy/ taxonomy.module - Implements hook_entity_query_alter().
File
-
modules/
system/ system.api.php, line 3318
Code
function hook_query_alter(QueryAlterableInterface $query) {
if ($query->hasTag('micro_limit')) {
$query->range(0, 2);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.