-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostgreSQLDriver.php
43 lines (38 loc) · 1.23 KB
/
PostgreSQLDriver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace ModernPDO\Drivers;
use ModernPDO\Drivers\Escapers\PostgreSQLEscaper;
use ModernPDO\Drivers\Factories\PostgreSQLFactory;
use ModernPDO\ModernPDO;
/**
* PostgreSQL wrapper over ModernPDO.
*/
class PostgreSQLDriver extends ModernPDO
{
/** Default PostgreSQL database port. */
public const DEFAULT_PORT = '5432';
/**
* Configures ModernPDO to work with PostgreSQL.
*
* @param string $host The hostname on which the database server reside
* @param string $database The name of the database
* @param string $username The user name for the DSN string
* @param string $password The password for the DSN string
* @param string $port Connection port, if empty, default is used
*
* @see https://www.php.net/manual/ru/ref.pdo-pgsql.php
*/
public function __construct(
string $host,
string $database,
string $username,
string $password,
string $port = self::DEFAULT_PORT,
) {
$pdo = new \PDO(
'pgsql:host=' . $host . ';dbname=' . $database . ';port=' . $port,
$username,
$password,
);
parent::__construct($pdo, PostgreSQLEscaper::class, PostgreSQLFactory::class);
}
}