Looking at the documentation for hook_query_alter(), I see that the parameter is reported to implement QueryAlterableInterface; looking at the code of _node_query_node_access_alter(), called by an implementation of hook_query_TAG_alter(), I notice that it is using methods not defined in the QueryAlterableInterface interface, such as $query->getTables().

If I implement hook_query_alter(), or hook_query_TAG_alter(), what methods should I use, and which methods can I effectively use?

link|improve this question

feedback

1 Answer

up vote 2 down vote accepted

In core, QueryAlterableInterface is extended by SelectQueryInterface, which is where you'll find SelectQueryInterface::getTables().

SelectQuery and SelectQueryExtender in turn implement SelectQueryInterface, and by extension, QueryAlterableInterface.

link|improve this answer
I guess that the argument for that hook should be defined as QueryAlterableInterface $query, then; the current definition would imply that you cannot count on methods implemented in SelectQueryInterface. – kiamlaluno Aug 19 '11 at 22:58
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.