Changeset 38280 for trunk/src/wp-includes/date.php
- Timestamp:
- 08/18/2016 07:47:15 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/date.php
r37518 r38280 62 62 */ 63 63 public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' ); 64 65 /** 66 * @since 4.7.0 67 * @access protected 68 * @var wpdb 69 */ 70 protected $db; 64 71 65 72 /** … … 152 159 */ 153 160 public function __construct( $date_query, $default_column = 'post_date' ) { 161 $this->db = $GLOBALS['wpdb']; 154 162 155 163 if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) { … … 487 495 */ 488 496 public function validate_column( $column ) { 489 global $wpdb;490 491 497 $valid_columns = array( 492 498 'post_date', 'post_date_gmt', 'post_modified', … … 513 519 514 520 $known_columns = array( 515 $ wpdb->posts => array(521 $this->db->posts => array( 516 522 'post_date', 517 523 'post_date_gmt', … … 519 525 'post_modified_gmt', 520 526 ), 521 $ wpdb->comments => array(527 $this->db->comments => array( 522 528 'comment_date', 523 529 'comment_date_gmt', 524 530 ), 525 $ wpdb->users => array(531 $this->db->users => array( 526 532 'user_registered', 527 533 ), 528 $ wpdb->blogs => array(534 $this->db->blogs => array( 529 535 'registered', 530 536 'last_updated', … … 718 724 */ 719 725 protected function get_sql_for_clause( $query, $parent_query ) { 720 global $wpdb;721 722 726 // The sub-parts of a $where part. 723 727 $where_parts = array(); … … 741 745 742 746 // Range queries. 743 if ( ! empty( $query['after'] ) ) 744 $where_parts[] = $ wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );745 746 if ( ! empty( $query['before'] ) ) 747 $where_parts[] = $ wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );748 747 if ( ! empty( $query['after'] ) ) { 748 $where_parts[] = $this->db->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); 749 } 750 if ( ! empty( $query['before'] ) ) { 751 $where_parts[] = $this->db->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); 752 } 749 753 // Specific value queries. 750 754 … … 959 963 */ 960 964 public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) { 961 global $wpdb;962 963 965 // Have to have at least one 964 966 if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) … … 1014 1016 } 1015 1017 1016 return $ wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );1018 return $this->db->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time ); 1017 1019 } 1018 1020 }
Note: See TracChangeset
for help on using the changeset viewer.