20250804
This commit is contained in:
56
sources/classes/tm_drivers/PostgreSQLTableManager.php
Normal file
56
sources/classes/tm_drivers/PostgreSQLTableManager.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @noinspection SqlNoDataSourceInspection
|
||||
*/
|
||||
|
||||
namespace goodboyalex\php_db_components_pack\classes\tm_drivers;
|
||||
|
||||
use goodboyalex\php_db_components_pack\classes\DataBaseHeader;
|
||||
use goodboyalex\php_db_components_pack\interfaces\ITableManager;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Система менеджмента таблицами базы данных PostgreSQL.
|
||||
*
|
||||
* @author Александр Бабаев
|
||||
* @package php_db_components_pack
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
final class PostgreSQLTableManager implements ITableManager
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function IsTableExist (PDO $handle, string $tableName): bool
|
||||
{
|
||||
// Создаю SQL-запрос
|
||||
$sql = "SELECT EXISTS(
|
||||
SELECT 1
|
||||
FROM pg_tables
|
||||
WHERE schemaname = current_schema()
|
||||
AND tablename = :tableName)";
|
||||
|
||||
// Подготавливаю данные
|
||||
$stmt = $handle->prepare($sql);
|
||||
|
||||
// Выполняю запрос
|
||||
$stmt->execute(['tableName' => $tableName]);
|
||||
|
||||
// Получаю количество таблиц, если = "true", то вывожу true, иначе - false
|
||||
return $stmt->fetchColumn() === 'true';
|
||||
}
|
||||
|
||||
public function CreateTable (PDO $handle, string $tableName, DataBaseHeader $columns): bool
|
||||
{
|
||||
// TODO: Implement CreateTable() method.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function DropTable (PDO $handle, string $tableName): bool
|
||||
{
|
||||
// TODO: Implement DropTable() method.
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user