82 lines
1.8 KiB
PHP
82 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Contracts;
|
|
|
|
interface DatabaseDriverInterface
|
|
{
|
|
/**
|
|
* Set the connection parameters and establish a connection.
|
|
*/
|
|
public function connect(array $config): bool;
|
|
|
|
/**
|
|
* Execute a raw query.
|
|
*/
|
|
public function query(string $sql, array $bindings = []): array;
|
|
|
|
/**
|
|
* Get the table schema.
|
|
*/
|
|
public function getTableSchema(string $table): array;
|
|
|
|
/**
|
|
* Get table data.
|
|
*/
|
|
public function getTableData(string $table, int $limit = 100, int $offset = 0, array $filters = []): array;
|
|
|
|
/**
|
|
* Get the count of rows in a table.
|
|
*/
|
|
public function getTableCount(string $table, array $filters = []): int;
|
|
|
|
/**
|
|
* Get the underlying connection instance.
|
|
*/
|
|
public function getConnection();
|
|
|
|
/**
|
|
* Export the database.
|
|
*/
|
|
public function export(array $config): string;
|
|
|
|
/**
|
|
* Import the database.
|
|
*/
|
|
public function import(array $config, string $filePath): bool;
|
|
|
|
/**
|
|
* Get database metadata (charset, collation, size, etc.)
|
|
*/
|
|
public function getDatabaseMetadata(string $database): array;
|
|
|
|
/**
|
|
* Get table metadata.
|
|
*/
|
|
public function getTableMetadata(string $database, string $table): array;
|
|
|
|
/**
|
|
* Get metadata for all tables in a database.
|
|
*/
|
|
public function getTablesMetadata(string $database): array;
|
|
|
|
/**
|
|
* Truncate a table.
|
|
*/
|
|
public function truncateTable(string $table): bool;
|
|
|
|
/**
|
|
* Drop a table.
|
|
*/
|
|
public function dropTable(string $table): bool;
|
|
|
|
/**
|
|
* Optimize a table.
|
|
*/
|
|
public function optimizeTable(string $table): bool;
|
|
|
|
/**
|
|
* Perform batch update on a table.
|
|
*/
|
|
public function batchUpdate(string $table, array $changes): bool;
|
|
}
|