예제 #1
0
파일: DBO.php 프로젝트: xdire/dude
 /**
  * DB constructor.
  * @param string|null $configInstance - Database instance from config file, for example: "mysql_connection"
  * @param bool $useReusableConnection - Set this to true to use DBManager to hold DBConnections for reuse
  *
  * @throws \Exception
  */
 function __construct($configInstance = null, $useReusableConnection = true)
 {
     $this->isTransaction = false;
     if (!isset($configInstance)) {
         # Apply parameters from config
         $this->config = App::getConfig('mysql_connection');
         if (isset($this->config)) {
             $this->constructDBOBJ($useReusableConnection);
             return;
         }
     } else {
         # Apply parameters from custom config instance
         $conf_cred = App::getConfig($configInstance);
         if (isset($conf_cred)) {
             $this->config = $conf_cred;
             $this->constructDBOBJ($useReusableConnection);
             return;
         }
     }
     throw new DBException("Database driver can't be instantiated. Failed to load configuration.", 500, "DB Connection failed", 500);
 }