function _hs_taxonomy_add_entity_bundles_condition_to_query in Hierarchical Select 7.3
Helper function to add entity_type and bundles to count query in form of a and/or combination.
Parameters
object $query: A db_select query object.
array $selected_bundles: An associative array of entities that contain bundles.
1 call to _hs_taxonomy_add_entity_bundles_condition_to_query()
- hs_taxonomy_hierarchical_select_entity_count in modules/
hs_taxonomy.module - Implementation of hook_hierarchical_select_entity_count().
File
- modules/
hs_taxonomy.module, line 1300 - Implementation of the Hierarchical Select API for the Taxonomy module.
Code
function _hs_taxonomy_add_entity_bundles_condition_to_query(&$query, $selected_bundles) {
$db_or = db_or();
foreach ($selected_bundles as $entity_type => $bundles) {
$db_and = db_and();
$db_and
->condition('ti.entity_type', $entity_type);
$db_and
->condition('ti.bundle', array_shift($bundles), 'IN');
$db_or
->condition($db_and);
}
$query
->condition($db_or);
}