2014-03-25 09:21:28 +00:00
|
|
|
<?php
|
|
|
|
namespace Helpers;
|
|
|
|
|
|
|
|
class PDO extends \PDO
|
|
|
|
{
|
|
|
|
private $debug = 0; //调试模式
|
|
|
|
|
|
|
|
private $config_local_path = "config/autoload/local.php";
|
|
|
|
|
|
|
|
public $db_cfg;
|
|
|
|
|
|
|
|
function __construct($DSN = NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(empty($DSN))
|
|
|
|
{
|
2015-01-30 15:24:25 +00:00
|
|
|
$config_local = \Zend_Registry::get('config');
|
2014-03-25 09:21:28 +00:00
|
|
|
$dsn = "pgsql:host={$config_local->db->hostname};"
|
|
|
|
."port=5432;"
|
|
|
|
."dbname={$config_local->db->database};"
|
|
|
|
."user={$config_local->db->username};"
|
|
|
|
."password={$config_local->db->password}";
|
|
|
|
parent::__construct($dsn);
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
if(is_string($DSN))
|
|
|
|
{
|
|
|
|
parent::__construct($DSN);
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
$dsn = "pgsql:host={$DSN['host']};"
|
|
|
|
."port={$DSN['port']};"
|
|
|
|
."dbname={$DSN['db']};"
|
|
|
|
."user={$DSN['user']};"
|
|
|
|
."password={$DSN['pwd']}";
|
|
|
|
parent::__construct($dsn);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|