36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
// IDbBackend.php
|
|
// Created: 2021-04-30
|
|
// Updated: 2022-02-28
|
|
|
|
namespace Index\Data;
|
|
|
|
/**
|
|
* Information about a database layer. Should not have any external dependencies.
|
|
*/
|
|
interface IDbBackend {
|
|
/**
|
|
* Checks whether the driver is available and a connection can be made.
|
|
*
|
|
* @return bool If true a connection can be made, if false a required extension is missing.
|
|
*/
|
|
function isAvailable(): bool;
|
|
|
|
/**
|
|
* Creates a connection with the database described in the argument.
|
|
*
|
|
* @param IDbConnectionInfo $connectionInfo Object that describes the desired connection.
|
|
* @throws \InvalidArgumentException An invalid implementation of IDbConnectionInfo was provided.
|
|
* @return IDbConnection A connection described in the connection info.
|
|
*/
|
|
function createConnection(IDbConnectionInfo $connectionInfo): IDbConnection;
|
|
|
|
/**
|
|
* Constructs a connection info instance from a dsn.
|
|
*
|
|
* @param string|array $dsn DSN with connection information.
|
|
* @return IDbConnectionInfo Connection info based on the dsn.
|
|
*/
|
|
function parseDsn(string|array $dsn): IDbConnectionInfo;
|
|
}
|