2014-11-04 09:05:21 +00:00
|
|
|
<?php
|
|
|
|
namespace Westdc\Db;
|
|
|
|
|
2015-01-23 08:27:48 +00:00
|
|
|
use Zend\Config\Config as Zend_Config;
|
2014-11-04 09:05:21 +00:00
|
|
|
|
2015-01-23 08:19:03 +00:00
|
|
|
class Pdo
|
2014-11-04 09:05:21 +00:00
|
|
|
{
|
2015-01-23 08:19:03 +00:00
|
|
|
|
|
|
|
private static $_instance = NULL;
|
2014-11-04 09:05:21 +00:00
|
|
|
|
2015-01-23 08:19:03 +00:00
|
|
|
private function __construct($DSN = NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getInstance()
|
2014-11-04 09:05:21 +00:00
|
|
|
{
|
2015-01-23 08:24:28 +00:00
|
|
|
|
2015-01-23 08:19:03 +00:00
|
|
|
if (self::$_instance === null) {
|
|
|
|
$config_local = new Zend_Config(include "config/autoload/local.php");
|
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}";
|
2015-01-23 08:19:03 +00:00
|
|
|
self::$_instance = new \PDO($dsn);
|
2014-11-04 09:05:21 +00:00
|
|
|
}
|
2015-01-23 08:19:03 +00:00
|
|
|
|
|
|
|
return self::$_instance;
|
2014-11-04 09:05:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|