Automattic\WooCommerce\Blueprint\Importers

ImportRunSql::affects_protected_tables │ private │ WC 1.0

Check if the SQL query affects protected user tables.

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

Хуков нет.

Возвращает

bool. True if the query affects protected tables, false otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->affects_protected_tables( $sql_content ): bool;
$sql_content(строка) (обязательный)
The SQL query to check.

Код ImportRunSql::affects_protected_tables() WC 11.2.2

private function affects_protected_tables( string $sql_content ): bool {
	global $wpdb;
	$protected_tables = array(
		$wpdb->users,
		$wpdb->usermeta,
	);

	foreach ( $protected_tables as $table ) {
		if ( preg_match( '/\b' . preg_quote( $table, '/' ) . '\b/i', $sql_content ) ) {
			return true;
		}
	}

	return false;
}