I’m new to Drupal 7, but not to Drupal. I’m afraid, however, that the new database query system is a bit over my head.
I’m attempting to alter a view query using hook_query_TAG_alter(). In essence, I’m attempting to append an OR to the filter, saying “list nodes where the current user is either referenced in a particular_field OR is the author.”
I’m attempting to append this last condition (or is the author) do this by adding a db_or()->condition(…) to the query, but I keep getting a fatal error:
Call to undefined method SelectQuery::db_or() in /Volumes/…
It’s driving me batshit, because I don’t understand this system enough to know why this method is unavailable. Here is my implementation:
function sentinel_network_query_views_networks_alter(QueryAlterableInterface $query) {
$query->db_or()->condition('node.uid', '***CURRENT_USER***', '=');
}
db_or()returns a database condition instance so you need to pass it to the query as a condition. Also, you need more than one condition indb_or()to actually perform an or!Hope that helps