Example #1
0
 /**
  * Returns initialized database object.
  *
  * @return \Mibew\Database|boolean A database class instance or boolean
  *   false if something went wrong.
  */
 protected function getDatabase()
 {
     if (!Database::isInitialized()) {
         try {
             Database::initialize($this->configs['database']['host'], $this->configs['database']['port'], $this->configs['database']['login'], $this->configs['database']['pass'], $this->configs['database']['use_persistent_connection'], $this->configs['database']['db'], $this->configs['database']['tables_prefix']);
         } catch (\PDOException $e) {
             $this->errors[] = getlocal("Could not connect. Please check server settings in config.yml. Error: {0}", array($e->getMessage()));
             return false;
         }
     }
     $db = Database::getInstance();
     $db->throwExceptions(true);
     return $db;
 }