Yoast\WP\SEO\Helpers

Wpdb_Helper::table_exists()publicYoast 1.0

Check if table exists.

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

Хуков нет.

Возвращает

true|false. Whether the table exists.

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

$Wpdb_Helper = new Wpdb_Helper();
$Wpdb_Helper->table_exists( $table );
$table(строка) (обязательный)
The table to be checked.

Код Wpdb_Helper::table_exists() Yoast 22.4

public function table_exists( $table ) {
	// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
	$table_exists = $this->wpdb->get_var( "SHOW TABLES LIKE '{$table}'" );
	if ( \is_wp_error( $table_exists ) || \is_null( $table_exists ) ) {
		return false;
	}

	return true;
}