Esempio n. 1
0
 /**
  * When running in production environment, we may want to e-mail all exceptions
  * @param $exception
  */
 public static function productionException($exception)
 {
     Exception::sendNotification($exception);
 }
Esempio n. 2
0
 /**
  * Connect to database
  * @throws Exception
  * @return void
  */
 protected function connect()
 {
     if ($this->connected === true) {
         return;
         //        } elseif ($this->connected === false) {
         //            throw new Exception('Database connection is not available');
     }
     $this->connected = false;
     try {
         $this->pdo = new \PDO($this->getConnectionString(), !empty($this->config['username']) ? $this->config['username'] : null, !empty($this->config['password']) ? $this->config['password'] : null, [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC]);
     } catch (\Exception $ex) {
         Exception::sendNotification($ex);
         throw new Exception("Database connection failed: {$this->config['name']}" . (Debugger::isEnabled() ? '(' . $ex->getMessage() . ')' : ''));
     }
     $this->connected = true;
 }