Changeset 38768 for trunk/src/wp-includes/class-wp-meta-query.php
- Timestamp:
- 10/10/2016 06:37:02 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-meta-query.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-meta-query.php
r38275 r38768 107 107 108 108 /** 109 * @since 4.7.0110 * @access protected111 * @var wpdb112 */113 protected $db;114 115 /**116 109 * Constructor. 117 110 * … … 145 138 */ 146 139 public function __construct( $meta_query = false ) { 147 $this->db = $GLOBALS['wpdb']; 148 149 if ( ! $meta_query ) { 140 if ( !$meta_query ) 150 141 return; 151 }152 142 153 143 if ( isset( $meta_query['relation'] ) && strtoupper( $meta_query['relation'] ) == 'OR' ) { … … 495 485 * @access public 496 486 * 487 * @global wpdb $wpdb WordPress database abstraction object. 488 * 497 489 * @param array $clause Query clause, passed by reference. 498 490 * @param array $parent_query Parent query array. … … 507 499 */ 508 500 public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) { 501 global $wpdb; 502 509 503 $sql_chunks = array( 510 504 'where' => array(), … … 544 538 $join .= " LEFT JOIN $this->meta_table"; 545 539 $join .= $i ? " AS $alias" : ''; 546 $join .= $ this->db->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] );540 $join .= $wpdb->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] ); 547 541 548 542 // All other JOIN clauses. … … 588 582 $sql_chunks['where'][] = $alias . '.' . $this->meta_id_column . ' IS NULL'; 589 583 } else { 590 $sql_chunks['where'][] = $ this->db->prepare( "$alias.meta_key = %s", trim( $clause['key'] ) );584 $sql_chunks['where'][] = $wpdb->prepare( "$alias.meta_key = %s", trim( $clause['key'] ) ); 591 585 } 592 586 } … … 608 602 case 'NOT IN' : 609 603 $meta_compare_string = '(' . substr( str_repeat( ',%s', count( $meta_value ) ), 1 ) . ')'; 610 $where = $ this->db->prepare( $meta_compare_string, $meta_value );604 $where = $wpdb->prepare( $meta_compare_string, $meta_value ); 611 605 break; 612 606 … … 614 608 case 'NOT BETWEEN' : 615 609 $meta_value = array_slice( $meta_value, 0, 2 ); 616 $where = $ this->db->prepare( '%s AND %s', $meta_value );610 $where = $wpdb->prepare( '%s AND %s', $meta_value ); 617 611 break; 618 612 619 613 case 'LIKE' : 620 614 case 'NOT LIKE' : 621 $meta_value = '%' . $ this->db->esc_like( $meta_value ) . '%';622 $where = $ this->db->prepare( '%s', $meta_value );615 $meta_value = '%' . $wpdb->esc_like( $meta_value ) . '%'; 616 $where = $wpdb->prepare( '%s', $meta_value ); 623 617 break; 624 618 … … 626 620 case 'EXISTS' : 627 621 $meta_compare = '='; 628 $where = $ this->db->prepare( '%s', $meta_value );622 $where = $wpdb->prepare( '%s', $meta_value ); 629 623 break; 630 624 … … 635 629 636 630 default : 637 $where = $ this->db->prepare( '%s', $meta_value );631 $where = $wpdb->prepare( '%s', $meta_value ); 638 632 break; 639 633
Note: See TracChangeset
for help on using the changeset viewer.