WP_Meta_Query::get_cast_for_type( string $type =  ): string

In this article

Returns the appropriate alias for the given meta type if applicable.

Parameters

$typestringoptional
MySQL type to cast meta_value.

Default:''

Return

string MySQL type.

Source

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;
}

Changelog

VersionDescription
3.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.