Index: modules/system/system.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v retrieving revision 1.20 diff -u -p -r1.20 system.api.php --- modules/system/system.api.php 26 Feb 2009 07:30:28 -0000 1.20 +++ modules/system/system.api.php 7 Mar 2009 17:33:34 -0000 @@ -1636,5 +1636,51 @@ function hook_disable() { } /** + * Allow modules to modify a dynamic query before it is run. + * + * All dynamic SELECT queries are run throug hook_query_alter() + * immediately prior to execution. That allows any module to + * make additions or alterations to the query object as needed. + * + * Most queries that are intended to be altered will have one + * or more query tags added to them. If so, query_alter implementations + * can use hasTag(), hasAllTags(), and hasAnyTag() to determine + * if they should run. + * * Note that because $query is an object it does not need + * to be passed by reference. There will still be only + * one instance of the object. Also note that the type + * hint is optional, but if used it should always use + * only QueryAlterableInterface, not SelectQueryInterface. + * + * @see QueryAlterableInterface + * @see SelectQueryInterface + * @param $query + * The query object to modify. + */ +function hook_query_alter(QueryAlterableInterface $query) { + + if ($query->hasTag('database_test_alter_add_range')) { + $query->range(0, 2); + } +} + +/** + * Alter queries that have a specific tag. + * + * This hook works identically to hook_query_alter(), but + * will only get called for queries that have been tagged + * with QUERY_TAG. + * + * @see hook_query_alter() + * @see QueryAlterableInterface + * @see SelectQueryInterface + * @param $query + * The query object to modify. + */ +function hook_query_QUERY_TAG_alter(QueryAlterableInterface $query) { + $query->range(); +} + +/** * @} End of "addtogroup hooks". */