Automattic\WooCommerce\Blueprint\Importers

ImportRunSql::affects_protected_tablesprivateWC 1.0

Check if the SQL query affects protected user tables.

Method of the class: ImportRunSql{}

No Hooks.

Returns

true|false. True if the query affects protected tables, false otherwise.

Usage

// private - for code of main (parent) class only
$result = $this->affects_protected_tables( $sql_content ): bool;
$sql_content(string) (required)
The SQL query to check.

ImportRunSql::affects_protected_tables() code WC 9.9.5

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