public function __construct($key = null)
 {
     $dbconfig = Config::getDBConfig($key);
     $connection = new mysqli($dbconfig['server'], $dbconfig['username'], base64_decode($dbconfig['password']), $dbconfig['database']);
     if ($connection->connect_error) {
         throw new Exception('Connection failed: ' . $connection->connect_error);
     }
     $connection->set_charset('utf8');
     $this->connection = $connection;
 }
 /**
  * @covers Config::getDBConfig
  * @todo Implement testGetDBConfig().
  */
 public function testGetDBConfig()
 {
     // Remove the following lines when you implement this test.
     $arr = $this->object->getDBConfig();
     $this->assertEquals('mysql', $arr[0]['dbtype']);
     $this->assertEquals('localhost:3306', $arr[0]['host']);
     $this->assertEquals('airymvc_unit_test', $arr[0]['database']);
     $this->assertEquals('root', $arr[0]['id']);
     $this->assertEquals('utf8', $arr[0]['encoding']);
     $this->assertEquals('mysqli', $arr[0]['connection_type']);
     $iniFile = dirname(dirname(dirname(__FILE__))) . '/testfiles/test_config_def.ini';
     $this->objectDefault->setIniFilePath($iniFile);
     $arr = $this->objectDefault->getDBConfig();
     $this->assertEquals('mysql', $arr['dbtype']);
     $this->assertEquals('localhost:3306', $arr['host']);
     $this->assertEquals('test2', $arr['database']);
     $this->assertEquals('root', $arr['id']);
     $this->assertEquals('utf8', $arr['encoding']);
     $this->assertEquals('mysql', $arr['connection_type']);
 }
Example #3
0
 function __construct($registry)
 {
     $this->registry = $registry;
     $config = new Config($this->registry);
     $this->defaultConnection = $config->getDefaultDBConnection();
     $dbData = $config->getDBConfig();
     foreach ($dbData as $key => $value) {
         $connections[$key] = "mysql://" . $value['USER'] . ":" . $value['PASS'] . "@" . $value['HOST'] . (isset($value['PORT']) ? ":" . $value['PORT'] : NULL) . "/" . $value['NAME'];
     }
     $this->connections = $connections;
     require $config->getORMPath();
     $this->invokeModel();
 }