Automattic\WooCommerce\Internal\Utilities

DatabaseUtil::get_wpdb_format_for_type()publicWC 1.0

Returns the $wpdb placeholder to use for data type $type.

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

Хуков нет.

Возвращает

Строку.

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

$DatabaseUtil = new DatabaseUtil();
$DatabaseUtil->get_wpdb_format_for_type( $type );
$type(строка) (обязательный)
Data type.

Код DatabaseUtil::get_wpdb_format_for_type() WC 8.7.0

public function get_wpdb_format_for_type( string $type ) {
	static $wpdb_placeholder_for_type = array(
		'int'        => '%d',
		'decimal'    => '%f',
		'string'     => '%s',
		'date'       => '%s',
		'date_epoch' => '%s',
		'bool'       => '%d',
	);

	if ( ! isset( $wpdb_placeholder_for_type[ $type ] ) ) {
		throw new \Exception( 'Invalid column type: ' . $type );
	}

	return $wpdb_placeholder_for_type[ $type ];
}