How do I mark a database query with a tag? How do I mark a database query with a tag so that I may alter it via hook_query_alter? I get the concept, but does anyone know what the syntax is? A working example would be helpful. Thanks.
In case you're struggling to find the documentation, the class is called SelectQuery, and you're looking for the addTag function.

$query = db_select('table', 't')-&gt;fields('t')-&gt;addTag('my_tag');


Then in your query alter:

function MYMODULE_query_alter(QueryAlterableInterface $query) {
  if ($query-&gt;hasTag('my_tag')) {
    // Do something...
  }
}