WP_Meta_Query::get_cast_for_type()
Returns the appropriate alias for the given meta type if applicable.
Method of the class: WP_Meta_Query{}
No Hooks.
Return
String
. MySQL type.
Usage
$WP_Meta_Query = new WP_Meta_Query(); $WP_Meta_Query->get_cast_for_type( $type );
- $type(string)
- MySQL type to cast meta_value.
Default: ''
Changelog
Since 3.7.0 | Introduced. |
WP_Meta_Query::get_cast_for_type() WP Meta Query::get cast for type code WP 6.4.3
public function get_cast_for_type( $type = '' ) { if ( empty( $type ) ) { return 'CHAR'; } $meta_type = strtoupper( $type ); if ( ! preg_match( '/^(?:BINARY|CHAR|DATE|DATETIME|SIGNED|UNSIGNED|TIME|NUMERIC(?:\(\d+(?:,\s?\d+)?\))?|DECIMAL(?:\(\d+(?:,\s?\d+)?\))?)$/', $meta_type ) ) { return 'CHAR'; } if ( 'NUMERIC' === $meta_type ) { $meta_type = 'SIGNED'; } return $meta_type; }