51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Nest\Database\PostgreSql;
|
|
|
|
use Nest\Database\DatabaseAdapter;
|
|
use Nest\Database\PdoDatabase;
|
|
|
|
class PostgreSqlDatabase extends PdoDatabase
|
|
{
|
|
/**
|
|
* @param string $host Database host or unix socket directory path.
|
|
* @param string $database Database name.
|
|
* @param string $username Username to use to connect to the database.
|
|
* @param string $password Password to use to connect to the database.
|
|
* @param int $port Database port.
|
|
*/
|
|
public function __construct(protected string $host, protected string $database, protected string $username, protected string $password, protected int $port = 5432)
|
|
{}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
#[\Override] public function getQueriesAdapter(): DatabaseAdapter
|
|
{
|
|
return new PostgreSqlAdapter($this);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
#[\Override] protected function getDsn(): string
|
|
{
|
|
return "pgsql:host={$this->host};port={$this->port};dbname={$this->database}";
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
#[\Override] protected function getUsername(): string
|
|
{
|
|
return $this->username;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
#[\Override] protected function getPassword(): string
|
|
{
|
|
return $this->password;
|
|
}
|
|
}
|