20250804
This commit is contained in:
49
sources/traits/Database/DatabaseTableManagement.php
Normal file
49
sources/traits/Database/DatabaseTableManagement.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @noinspection SqlNoDataSourceInspection
|
||||
*/
|
||||
|
||||
namespace goodboyalex\php_db_components_pack\traits\Database;
|
||||
|
||||
use goodboyalex\php_db_components_pack\classes\tm_drivers\MSSQLTableManager;
|
||||
use goodboyalex\php_db_components_pack\classes\tm_drivers\MySQLTableManager;
|
||||
use goodboyalex\php_db_components_pack\classes\tm_drivers\OracleDBTableManager;
|
||||
use goodboyalex\php_db_components_pack\classes\tm_drivers\PostgreSQLTableManager;
|
||||
use goodboyalex\php_db_components_pack\classes\tm_drivers\SQLiteTableManager;
|
||||
use goodboyalex\php_db_components_pack\enums\DBDriver;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Трейт для управления таблицами базы данных.
|
||||
*
|
||||
* @author Александр Бабаев
|
||||
* @package php_components_pack
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
* @see PDO
|
||||
*/
|
||||
trait DatabaseTableManagement
|
||||
{
|
||||
/**
|
||||
* Проверяет, существует ли таблица.
|
||||
*
|
||||
* @param string $tableName Имя таблицы.
|
||||
*
|
||||
* @return bool Результат проверки: <code>true</code> - таблица существует, <code>false</code> - не существует.
|
||||
*/
|
||||
public function IsTableExist (string $tableName): bool
|
||||
{
|
||||
// Получаю систему управления таблицами БД
|
||||
$dbDrv = match ($this->Config->Driver) {
|
||||
DBDriver::MySQL => new MySQLTableManager(),
|
||||
DBDriver::MSSQL => new MSSQLTableManager(),
|
||||
DBDriver::PostgreSQL => new PostgreSQLTableManager(),
|
||||
DBDriver::OracleDB => new OracleDBTableManager(),
|
||||
DBDriver::SQLite => new SQLiteTableManager()
|
||||
};
|
||||
|
||||
// Проверяю существование таблицы, вывожу результат
|
||||
return $dbDrv->isTableExist($this->DataBaseHandle, $tableName);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user