westdc-zf1/vendor/Sookon/Helpers/PDO.php

29 lines
653 B
PHP

<?php
namespace Sookon\Helpers;
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)
{
$config_local = new Zend_Config(include $this->config_local_path);
if(!empty($DSN))
{
parent::__construct($DSN);
}else{
$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);
}
}
}