Beispiel #1
0
 public function testデータベースアダプターを取得できる()
 {
     $iniPath = GENE_TEST_ROOT . '/var/config/database.ini';
     $config = Gene_Config::load($iniPath);
     $db = new Gene_Db_Setting_Zend($config->production);
     $adapter = $db->load()->getDbAdapter();
     $this->assertTrue($adapter instanceof Zend_Db_Adapter_Pdo_Mysql);
 }
Beispiel #2
0
 /**
  * trancate
  *
  * @param  mixed $ini
  * @param  mixed $sql
  * @param  string $section
  * @param  string $key
  * @access public
  * @return void
  */
 public static function trancate($ini, $sql, $section = 'testing', $key = 'default')
 {
     $config = Gene_Config::load($ini)->{$section};
     $name = $config->setting->className;
     if ($name !== 'Gene_Db_Setting_Zend') {
         if ($config->database->default->adapter !== 'Pdo_Mysql') {
             $config = $config->database->toArray();
             $config['default']['adapter'] = 'Pdo_Mysql';
         }
     }
     $db = new Gene_Db_Setting_Zend($config);
     $adapter = $db->load()->getDbAdapter($key);
     $adapter->getConnection()->exec(file_get_contents($sql));
     self::$_adapter = $adapter;
 }