WP_Meta_Query::get_cast_for_type()publicWP 3.7.0

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

Метод класса: WP_Meta_Query{}

Хуков нет.

Возвращает

Строку. MySQL type.

Использование

$WP_Meta_Query = new WP_Meta_Query();
$WP_Meta_Query->get_cast_for_type( $type );
$type(строка)
MySQL type to cast meta_value.
По умолчанию: ''

Список изменений

С версии 3.7.0 Введена.

Код WP_Meta_Query::get_cast_for_type() WP 6.5.2

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