Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach ( $all as $vocab => $value ) {
- foreach ( $value as $field => $terms ) {
- // we only support these fields to search by
- if ( !in_array( $field, array( 'id', 'term', 'term_display' ) ) ) {
- continue;
- }
- $query->join( 'JOIN {object_terms} ON {posts}.id = {object_terms}.object_id', array(), 'term2post_posts' );
- $query->join( 'JOIN {terms} ON {object_terms}.term_id = {terms}.id', array(), 'terms_term2post' );
- $query->join( 'JOIN {vocabularies} ON {terms}.vocabulary_id = {vocabularies}.id', array(), 'terms_vocabulary' );
- $vocab_name = Query::new_param_name( 'vocab_any');
- $obid_name = Query::new_param_name( 'oid_any' );
- $where->add( "{vocabularies}.name = :{$vocab_name}", array( $vocab_name => $vocab) );
- $term_where = new QueryWhere();
- $term_where->in( "{terms}.{$field}", $terms );
- $oid_where = new QueryWhere();
- $oid_where->add( "{object_terms}.object_type_id = :{$obid_name}", array( $obid_name => $object_id ) );
- $where->add( $term_where );
- $where->add( $oid_where );
- }
- // this causes no posts to match if combined with 'any' below and should be re-thought... somehow
- $query->groupby( implode( ',', $select_distinct ) );
- $having = 'count(*) = ' . count( $terms );
- }
Add Comment
Please, Sign In to add comment