Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
taxonomy_select_nodes() would be a more useful API function if if supported the multi-term arguments from older versions of Drupal.
I'd like to see $tids = array(), $operator = 'or'
restored to the arguments of the D7 version.
Issue fork drupal-607492
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
jweowu CreditAttribution: jweowu commentedI'm struggling with the new DB abstraction with this one. Perhaps someone more knowledgeable could have a look?
It seems that
$query = db_select('taxonomy_index', 't');
intaxonomy_select_nodes()
creates aSelectQuery
object, and the constructor for that explicitly sets the conjunction for its DatabaseCondition to 'AND' with$this->where = new DatabaseCondition('AND');
So although we could call
$query->condition('tid', $tid);
repeatedly for multiple term IDs, we'd need the conjunction to be 'OR' for it to return any values (as no row in the taxonomy_index table can have multiple different terms).I don't see any API for replacing the DatabaseCondition (SelectQuery's private property
$where
) with another one with a different conjunction.At this point, I'm wanting to resort to a normal SQL query to do this, so some help would be much appreciated.