for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DrMVC\Database\Drivers;
class Pgsql extends SQL
{
const DEFAULT_HOST = '127.0.0.1';
const DEFAULT_PORT = '5432';
/**
* @link https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php
* @link https://www.postgresql.org/docs/8.3/static/libpq-connect.html
*
* The PDO_PGSQL Data Source Name (DSN) is composed of the following elements:
*/
const AVAILABLE_ELEMENTS = [
'host',
'hostaddr',
'port',
'dbname',
* These two parameters below is not needed, because we can put user/pass
* as parameters of PDO class, you can read more by link
* @link https://secure.php.net/manual/en/pdo.construct.php
//'user',
//'password',
'passfile',
'connect_timeout',
'client_encoding',
'options',
'application_name',
'fallback_application_name',
'keepalives',
'keepalives_idle',
'keepalives_interval',
'keepalives_count',
'tty',
'sslmode',
'requiressl',
'sslcompression',
'sslcert',
'sslkey',
'sslrootcert',
'sslcrl',
'requirepeer',
'krbsrvname',
'gsslib',
'service',
'target_session_attrs'
];
* Generate DSN by parameters in config
* @param array $config
* @return string
public function genDsn($config): string
// Parse config
$dsn = '';
foreach ($config as $key => $value) {
if (\in_array($key, self::AVAILABLE_ELEMENTS, false)) {
$dsn .= "$key=$value;";
}
return $dsn;