Changeset 16267 for trunk/wp-includes/class-wp-object-query.php
- Timestamp:
- 11/09/2010 11:30:35 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/class-wp-object-query.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-object-query.php
r16266 r16267 73 73 74 74 /* 75 * Used internally to generate an SQL string for searching across multiple taxonomies76 *77 * @access protected78 * @since 3.1.079 *80 * @param array $tax_query List of taxonomy queries. A single taxonomy query is an associative array:81 * - 'taxonomy' string|array The taxonomy being queried82 * - 'terms' string|array The list of terms83 * - 'field' string (optional) Which term field is being used.84 * Possible values: 'term_id', 'slug' or 'name'85 * Default: 'slug'86 * - 'operator' string (optional)87 * Possible values: 'IN' and 'NOT IN'.88 * Default: 'IN'89 * - 'include_children' bool (optional) Whether to include child terms.90 * Default: true91 *92 * @param string $object_id_column93 * @return string94 */95 function get_tax_sql( $tax_query, $object_id_column ) {96 global $wpdb;97 98 $sql = array();99 foreach ( $tax_query as $query ) {100 if ( !isset( $query['include_children'] ) )101 $query['include_children'] = true;102 103 $query['do_query'] = false;104 105 $sql_single = get_objects_in_term( $query['terms'], $query['taxonomy'], $query );106 107 if ( empty( $sql_single ) )108 return ' AND 0 = 1';109 110 $sql[] = $sql_single;111 }112 113 if ( 1 == count( $sql ) ) {114 $ids = $wpdb->get_col( $sql[0] );115 } else {116 $r = "SELECT object_id FROM $wpdb->term_relationships WHERE 1=1";117 foreach ( $sql as $query )118 $r .= " AND object_id IN ($query)";119 120 $ids = $wpdb->get_col( $r );121 }122 123 if ( !empty( $ids ) )124 return " AND $object_id_column IN(" . implode( ', ', $ids ) . ")";125 else126 return ' AND 0 = 1';127 }128 129 /*130 75 * Used internally to generate an SQL string for searching across multiple columns 131 76 *
Note: See TracChangeset
for help on using the changeset viewer.