Guest User

Untitled

a guest
Jan 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. foreach ( $all as $vocab => $value ) {
  2.  
  3. foreach ( $value as $field => $terms ) {
  4.  
  5. // we only support these fields to search by
  6. if ( !in_array( $field, array( 'id', 'term', 'term_display' ) ) ) {
  7. continue;
  8. }
  9.  
  10. $query->join( 'JOIN {object_terms} ON {posts}.id = {object_terms}.object_id', array(), 'term2post_posts' );
  11. $query->join( 'JOIN {terms} ON {object_terms}.term_id = {terms}.id', array(), 'terms_term2post' );
  12. $query->join( 'JOIN {vocabularies} ON {terms}.vocabulary_id = {vocabularies}.id', array(), 'terms_vocabulary' );
  13.  
  14. $vocab_name = Query::new_param_name( 'vocab_any');
  15. $obid_name = Query::new_param_name( 'oid_any' );
  16.  
  17. $where->add( "{vocabularies}.name = :{$vocab_name}", array( $vocab_name => $vocab) );
  18. $term_where = new QueryWhere();
  19. $term_where->in( "{terms}.{$field}", $terms );
  20. $oid_where = new QueryWhere();
  21. $oid_where->add( "{object_terms}.object_type_id = :{$obid_name}", array( $obid_name => $object_id ) );
  22. $where->add( $term_where );
  23. $where->add( $oid_where );
  24. }
  25.  
  26. // this causes no posts to match if combined with 'any' below and should be re-thought... somehow
  27. $query->groupby( implode( ',', $select_distinct ) );
  28. $having = 'count(*) = ' . count( $terms );
  29.  
  30. }
Add Comment
Please, Sign In to add comment