WP_Meta_Query::get_cast_for_type

Advertisement

Summery Summery

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

Syntax Syntax

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

Parameters Parameters

$type

(string) (Optional) MySQL type to cast meta_value.

Default value: ''

Return Return

(string) MySQL type.

Source Source

File: wp-includes/class-wp-meta-query.php

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

Advertisement

Changelog Changelog

Changelog
Version Description
3.7.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.