Exemple #1
0
 /**
  *
  * @param type $force
  * @return type
  */
 public function getMySqlDB($force = false)
 {
     if (is_null($this->mySqlDB) || $force) {
         $username = \Config::$MYSQL_USERNAME;
         $password = \Config::$MYSQL_PASSWORD;
         $database = \Config::$MYSQL_DATABASE;
         if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
             $username = \Config::$MYSQL_USERNAME_TEST;
             $password = \Config::$MYSQL_PASSWORD_TEST;
             $database = \Config::$MYSQL_DATABASE_TEST;
         }
         $this->mySqlDB = new Database(\Config::$MYSQL_HOST, $username, $password, $database, \Config::$DEBUG);
         if (!$this->mySqlDB) {
             throw new Exception('Can not connect to Mysql mySqlDB using mysqli driver.');
         }
     }
     if (\Config::$DEBUG) {
         // TEMP HACK:
         $q = 'SET foreign_key_checks = 0;';
         $this->mySqlDB->q($q);
     }
     return $this->mySqlDB;
 }