Changeset 25269
- Timestamp:
- 09/05/2013 11:31:28 PM (13 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/meta.php
r25255 r25269 604 604 } 605 605 606 /**607 * Given a meta type, return the appropriate alias if applicable608 *609 * @since 3.7.0610 *611 * @see WP_Meta_Query612 *613 * @param string $type MySQL type to cast meta_value614 * @return string MySQL type615 */616 function get_meta_type( $type = '' ) {617 if ( empty( $type ) )618 return 'CHAR';619 620 $meta_type = strtoupper( $type );621 622 if ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED', 'NUMERIC' ) ) )623 return 'CHAR';624 625 if ( 'NUMERIC' == $meta_type )626 $meta_type = 'SIGNED';627 628 return $meta_type;629 }630 606 /** 631 607 * Container class for a multiple metadata query … … 714 690 715 691 /** 692 * Given a meta type, return the appropriate alias if applicable 693 * 694 * @since 3.7.0 695 * 696 * @param string $type MySQL type to cast meta_value 697 * @return string MySQL type 698 */ 699 function get_cast_for_type( $type = '' ) { 700 if ( empty( $type ) ) 701 return 'CHAR'; 702 703 $meta_type = strtoupper( $type ); 704 705 if ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED', 'NUMERIC' ) ) ) 706 return 'CHAR'; 707 708 if ( 'NUMERIC' == $meta_type ) 709 $meta_type = 'SIGNED'; 710 711 return $meta_type; 712 } 713 714 /** 716 715 * Generates SQL clauses to be appended to a main query. 717 716 * … … 769 768 foreach ( $queries as $k => $q ) { 770 769 $meta_key = isset( $q['key'] ) ? trim( $q['key'] ) : ''; 771 $meta_type = get_meta_type( isset( $q['type'] ) ? $q['type'] : '' );770 $meta_type = $this->get_cast_for_type( isset( $q['type'] ) ? $q['type'] : '' ); 772 771 773 772 $meta_value = isset( $q['value'] ) ? $q['value'] : null; -
trunk/src/wp-includes/query.php
r25255 r25269 2422 2422 case 'meta_value': 2423 2423 if ( isset( $q['meta_type'] ) ) { 2424 $meta_type = get_meta_type( $q['meta_type'] );2424 $meta_type = $this->meta_query->get_cast_for_type( $q['meta_type'] ); 2425 2425 $orderby = "CAST($wpdb->postmeta.meta_value AS {$meta_type})"; 2426 2426 } else { 2427 2427 $orderby = "$wpdb->postmeta.meta_value"; 2428 } 2428 } 2429 2429 break; 2430 2430 case 'meta_value_num':
Note: See TracChangeset
for help on using the changeset viewer.