Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableMetaQuery::sanitize_cast_type()privateWC 1.0

Returns the correct type for a given meta type.

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

No Hooks.

Return

String. MySQL type.

Usage

// private - for code of main (parent) class only
$result = $this->sanitize_cast_type( $type ): string;
$type(string)
MySQL type.
Default: ''

Code of OrdersTableMetaQuery::sanitize_cast_type() WC 7.1.0

private function sanitize_cast_type( string $type = '' ): string {
	$meta_type = strtoupper( $type );

	if ( ! $meta_type || ! 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;
}