Example #1
0
 /**
  * Creates and returns a PDO object.
  *
  * @static
  * @return PDO
  */
 protected static function getConn()
 {
     if (Db::getInstance()->pdo != null) {
         return Db::getInstance()->pdo;
     }
     $dsnCfg = Config::getDbDsn();
     $dbAuth = Config::getDbAuth();
     $dsn = $dsnCfg['driver'] . ':' . http_build_query($dsnCfg['dsn_opts'], '', ';');
     self::$dbName = $dsnCfg['dsn_opts']['dbname'];
     try {
         Db::getInstance()->pdo = new PDO($dsn, $dbAuth['uname'], $dbAuth['passwd'], array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
     } catch (Exception $e) {
         die($e->getMessage());
     }
     # Don't want this floating around all willy nilly
     $dbAuth = null;
     return Db::getInstance()->pdo;
 }