From f5cab8c0a107cd50c81b2242153ceb6efc3a7fa9 Mon Sep 17 00:00:00 2001 From: Bugo Date: Wed, 4 Dec 2024 11:29:25 +0500 Subject: [PATCH] Extend DbFuncMapper --- src/Compat/DbFuncMapper.php | 89 +++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/src/Compat/DbFuncMapper.php b/src/Compat/DbFuncMapper.php index 54536b6..024eeed 100644 --- a/src/Compat/DbFuncMapper.php +++ b/src/Compat/DbFuncMapper.php @@ -20,11 +20,9 @@ class DbFuncMapper { public function __call(string $name, array $arguments) { - // @codeCoverageIgnoreStart if (array_key_exists('db_' . $name, Utils::$smcFunc)) { ErrorHandler::log('[LP] This function is not implemented yet: ' . $name); } - // @codeCoverageIgnoreEnd return false; } @@ -76,7 +74,7 @@ public function transaction(string $type = 'commit'): bool return Utils::$smcFunc['db_transaction']($type); } - public function optimize_table(string $table): int + public function optimize_table(string $table): int|float { Db::extend(); @@ -97,6 +95,46 @@ public function get_version(): string return Utils::$smcFunc['db_get_version'](); } + public function get_vendor(): string + { + Db::extend(); + + return Utils::$smcFunc['db_get_vendor'](); + } + + public function add_column( + string $table_name, + array $column_info, + array $parameters = [], + string $if_exists = 'update', + string $error = 'fatal' + ): bool + { + Db::extend('packages'); + + return Utils::$smcFunc['db_add_column']($table_name, $column_info, $parameters, $if_exists, $error); + } + + public function add_index( + string $table_name, + array $index_info, + array $parameters = [], + string $if_exists = 'update', + string $error = 'fatal' + ): bool + { + Db::extend('packages'); + + return Utils::$smcFunc['db_add_index']($table_name, $index_info, $parameters, $if_exists, $error); + } + + public function change_column(string $table_name, string $old_column, array $column_info): bool + { + Db::extend('packages'); + + return Utils::$smcFunc['db_change_column']($table_name, $old_column, $column_info); + } + public function create_table( string $table_name, array $columns, @@ -110,4 +148,49 @@ public function create_table( return Utils::$smcFunc['db_create_table']($table_name, $columns, $indexes, $parameters, $if_exists, $error); } + + public function table_structure(string $table_name): array + { + Db::extend('packages'); + + return Utils::$smcFunc['db_table_structure']($table_name); + } + + public function list_columns(string $table_name, bool $detail = false, array $parameters = []): array + { + Db::extend('packages'); + + return Utils::$smcFunc['db_list_columns']($table_name, $detail, $parameters); + } + + public function list_indexes(string $table_name, bool $detail = false, array $parameters = []): array + { + Db::extend('packages'); + + return Utils::$smcFunc['db_list_indexes']($table_name, $detail, $parameters); + } + + public function remove_column( + string $table_name, + string $column_name, + array $parameters = [], + string $error = 'fatal' + ): bool + { + Db::extend('packages'); + + return Utils::$smcFunc['db_remove_column']($table_name, $column_name, $parameters, $error); + } + + public function remove_index( + string $table_name, + string $index_name, + array $parameters = [], + string $error = 'fatal' + ): bool + { + Db::extend('packages'); + + return Utils::$smcFunc['db_remove_index']($table_name, $index_name, $parameters, $error); + } }