How do I remove the "where" clause from a structured query object in hook_query_alter()? Jumping off of this question, I'd like to know how to gracefully detect and remove each snippet in the WHERE clause of my query object in plain old hook_query_alter(), not hook_views_query_alter() (as the Views query object seems structured in some entirely different way (frustrating!).  The documentation vaguely suggests that this is possible by showing how you can create a reference to your query conditions that you can then manipulate, by starting with this:

$where =&amp; $query-&gt;conditions();


... but the object(s) within are utterly confusing, and I've been struggling to remove or replace existing snippets.  I've explored /includes/select.inc and /includes/query.inc but the classes therein don't seem to provide any methods for fine-tune manipulation.
That's pretty much all there is to it: in hook_query_alter() you only have access the query object from "outside" and, since there is no public API to remove conditions, it's kinda confusing.

However, there's some clever php hackery going on so if you call $where =&amp; $query-&gt;conditions(); or any of the other examples in the documentation you linked it will return a reference to that corresponding variable.

So, in the where example above, you gain access to $query-&gt;where protected class variable.  If you inspect them you will see they are just basic php arrays containing all of the information and you can literally just unset something on that reference and be done.

So:


$where =&amp; $query-&gt;conditions();
// Remove the second condition. 
unset($where[1]);


Finally, specifically with where queries, you want to be mindful of the #conjunction and eventual more complex and/or grouping stuff.