Skip to content

Commit

Permalink
Extend DbFuncMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Dec 4, 2024
1 parent 8768e0a commit f5cab8c
Showing 1 changed file with 86 additions and 3 deletions.
89 changes: 86 additions & 3 deletions src/Compat/DbFuncMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();

Expand All @@ -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,
Expand All @@ -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);
}
}

0 comments on commit f5cab8c

Please sign in to comment.