2014-11-04 09:05:21 +00:00
|
|
|
<?php
|
|
|
|
namespace Westdc\Db;
|
|
|
|
|
|
|
|
use Zend\Config\Config as Zend_Config;
|
|
|
|
|
|
|
|
class Pdo extends \PDO
|
|
|
|
{
|
|
|
|
private $debug = 0; //调试模式
|
|
|
|
|
|
|
|
private $config_local_path = "config/autoload/local.php";
|
|
|
|
|
|
|
|
function __construct($DSN = NULL)
|
|
|
|
{
|
|
|
|
if (!empty($DSN)) {
|
|
|
|
parent::__construct($DSN);
|
|
|
|
} else {
|
|
|
|
$config_local = new Zend_Config(include $this->config_local_path);
|
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|