2014-11-04 09:05:21 +00:00
|
|
|
<?php
|
|
|
|
namespace Westdc\Db;
|
|
|
|
|
2015-01-11 03:24:31 +00:00
|
|
|
use Westdc\Helpers\Config;
|
2014-11-04 09:05:21 +00:00
|
|
|
|
|
|
|
class Pdo extends \PDO
|
|
|
|
{
|
|
|
|
|
|
|
|
function __construct($DSN = NULL)
|
|
|
|
{
|
|
|
|
if (!empty($DSN)) {
|
|
|
|
parent::__construct($DSN);
|
|
|
|
} else {
|
2015-01-11 03:24:31 +00:00
|
|
|
$config_local = Config::get('local');
|
2014-11-04 09:05:21 +00:00
|
|
|
|
|
|
|
$dsn = "pgsql:host={$config_local->db->hostname};"
|
2014-12-13 04:02:01 +00:00
|
|
|
. "port={$config_local->db->port};"
|
2014-11-04 09:05:21 +00:00
|
|
|
. "dbname={$config_local->db->database};"
|
|
|
|
. "user={$config_local->db->username};"
|
|
|
|
. "password={$config_local->db->password}";
|
|
|
|
parent::__construct($dsn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|