Ejemplo n.º 1
0
 /**
  * Get the DB connection.
  * 
  * @return DB
  */
 public static function conn()
 {
     // Auto connect using Jasny's Config class
     if (!isset(self::$connection)) {
         if (!class_exists('Jasny\\Config') || !isset(\Jasny\Config::i()->db)) {
             throw new DB_Exception("Unable to create DB connection: not configured");
         }
         new static(\Jasny\Config::i()->db);
     }
     return self::$connection;
 }
Ejemplo n.º 2
0
 /**
  * Get the DB connection.
  * 
  * @return DB
  */
 public static function conn()
 {
     // Auto connect using Jasny's Config class
     if (!isset(self::$connection)) {
         if (!class_exists('Jasny\\Config') || !isset(\Jasny\Config::i()->db)) {
             throw new DB_Exception("Unable to create DB connection: not configured");
         }
         $cfg = \Jasny\Config::i()->db;
         new static(isset($cfg->host) ? $cfg->host : 'localhost', $cfg->username, $cfg->password, isset($cfg->dbname) ? $cfg->dbname : null, isset($cfg->port) ? $cfg->port : null);
     }
     return self::$connection;
 }