Ticket #12891: relation-or.diff
File relation-or.diff, 1.1 KB (added by , 15 years ago) |
---|
-
taxonomy.php
526 526 $join = ''; 527 527 $where = ''; 528 528 $i = 0; 529 if ( !empty( $tax_query['relation'] ) ) { 530 $relation = $tax_query['relation']; 531 } else { 532 $relation = 'AND'; 533 } 529 534 foreach ( $tax_query as $query ) { 535 if ( !is_array( $query ) ) continue; 536 530 537 extract( wp_parse_args( $query, array( 531 538 'taxonomy' => array(), 532 539 'terms' => array(), … … 576 583 $join .= " INNER JOIN $wpdb->term_relationships"; 577 584 $join .= $i ? " AS $alias" : ''; 578 585 $join .= " ON ($primary_table.$primary_id_column = $alias.object_id)"; 586 587 if ($i) $where .= " $relation"; 588 589 $where .= " $alias.term_taxonomy_id $operator ($terms)"; 579 590 580 $where .= " AND $alias.term_taxonomy_id $operator ($terms)";581 582 591 $i++; 583 592 } 584 593 elseif ( 'NOT IN' == $operator ) { … … 594 603 )"; 595 604 } 596 605 } 606 if ( 'IN' == $operator ) { 607 $where = ' AND ( ' . $where . ' )'; 608 } 597 609 598 610 return compact( 'join', 'where' ); 599 611 }