Changeset 45590 for trunk/src/wp-includes/date.php
- Timestamp:
- 07/02/2019 11:41:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/date.php
r45424 r45590 740 740 // Specific value queries. 741 741 742 if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) { 743 $where_parts[] = "YEAR( $column ) $compare $value"; 744 } 745 746 if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) { 747 $where_parts[] = "MONTH( $column ) $compare $value"; 748 } elseif ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) { 749 $where_parts[] = "MONTH( $column ) $compare $value"; 750 } 751 if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) { 752 $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; 753 } elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) { 754 $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; 755 } 756 if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) { 757 $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; 758 } 759 760 if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) { 761 $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; 762 } 763 764 if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) { 765 $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; 766 } 767 768 if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) { 769 $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; 742 $date_units = array( 743 'YEAR' => array( 'year' ), 744 'MONTH' => array( 'month', 'monthnum' ), 745 '_wp_mysql_week' => array( 'week', 'w' ), 746 'DAYOFYEAR' => array( 'dayofyear' ), 747 'DAYOFMONTH' => array( 'day' ), 748 'DAYOFWEEK' => array( 'dayofweek' ), 749 'WEEKDAY' => array( 'dayofweek_iso' ), 750 ); 751 752 // Check of the possible date units and add them to the query 753 foreach ( $date_units as $sql_part => $query_parts ) { 754 foreach ( $query_parts as $query_part ) { 755 if ( isset( $query[ $query_part ] ) ) { 756 $value = $this->build_value( $compare, $query[ $query_part ] ); 757 if ( $value ) { 758 switch ( $sql_part ) { 759 case '_wp_mysql_week': 760 $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; 761 break; 762 case 'WEEKDAY': 763 $where_parts[] = "$sql_part( $column ) + 1 $compare $value"; 764 break; 765 default: 766 $where_parts[] = "$sql_part( $column ) $compare $value"; 767 } 768 769 break; 770 } 771 } 772 } 770 773 } 771 774 … … 778 781 } 779 782 780 if ( $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ) ) { 783 $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ); 784 if ( $time_query ) { 781 785 $where_parts[] = $time_query; 782 786 } … … 970 974 $return = array(); 971 975 972 if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { 976 $value = $this->build_value( $compare, $hour ); 977 if ( false !== $value ) { 973 978 $return[] = "HOUR( $column ) $compare $value"; 974 979 } 975 980 976 if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { 981 $value = $this->build_value( $compare, $minute ); 982 if ( false !== $value ) { 977 983 $return[] = "MINUTE( $column ) $compare $value"; 978 984 } 979 985 980 if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { 986 $value = $this->build_value( $compare, $second ); 987 if ( false !== $value ) { 981 988 $return[] = "SECOND( $column ) $compare $value"; 982 989 } … … 986 993 987 994 // Cases where just one unit is set 988 if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { 989 return "HOUR( $column ) $compare $value"; 990 } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { 991 return "MINUTE( $column ) $compare $value"; 992 } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { 993 return "SECOND( $column ) $compare $value"; 995 if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) { 996 $value = $this->build_value( $compare, $hour ); 997 if ( false !== $value ) { 998 return "HOUR( $column ) $compare $value"; 999 } 1000 } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) ) { 1001 $value = $this->build_value( $compare, $minute ); 1002 if ( false !== $value ) { 1003 return "MINUTE( $column ) $compare $value"; 1004 } 1005 } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) ) { 1006 $value = $this->build_value( $compare, $second ); 1007 if ( false !== $value ) { 1008 return "SECOND( $column ) $compare $value"; 1009 } 994 1010 } 995 1011 … … 999 1015 } 1000 1016 1001 $format = $time = ''; 1017 $format = ''; 1018 $time = ''; 1002 1019 1003 1020 // Hour
Note: See TracChangeset
for help on using the changeset viewer.