get_col( $db->prepare( 'SHOW TABLES LIKE %s', $db->esc_like( $prefix ) . '%' ) ); return array_map( 'strval', (array) $names ); } /** * Drops every scratch table with the given prefix. */ public static function dropAll( \wpdb $db, string $prefix ): void { $names = self::listWithPrefix( $db, $prefix ); if ( ! $names ) { return; } $conn = new Connection( $db ); $conn->exec( 'DROP TABLE IF EXISTS ' . implode( ',', array_map( array( Sql::class, 'ident' ), $names ) ) ); } /** * The scratch name for a destination table, or null if it would exceed MySQL's 64 character limit. */ public static function tmpName( string $destination ): ?string { $name = self::TMP . $destination; return strlen( $name ) <= 64 ? $name : null; } public static function oldName( string $destination ): ?string { $name = self::OLD . $destination; return strlen( $name ) <= 64 ? $name : null; } }