コード例 #1
0
ファイル: ci-test.php プロジェクト: joeymetal/v1
 function _checkDbConfig($type, $settings = array())
 {
     $this->debug('Checking if database config for "' . $type . '" is available');
     require_once AK_BASE_DIR . DS . 'lib' . DS . 'AkActiveRecord' . DS . 'AkDbAdapter.php';
     require_once AK_LIB_DIR . DS . 'Ak.php';
     if (empty($settings)) {
         require_once AK_BASE_DIR . DS . 'lib' . DS . 'AkConfig.php';
         $config = new AkConfig();
         $settings = $config->get($type, 'testing');
     }
     $db = new AkDbAdapter($settings);
     $db->connect(false);
     if (!($res = $db->connected())) {
         $this->error("[{$type}] " . 'Cannot connect to DB');
     } else {
         $this->info("[{$type}] " . 'Successfully connected to database ' . ($settings['type'] == 'sqlite' ? $settings['database_file'] : $settings['database_name']));
         $createRes = $db->execute('CREATE table ci_test_dummy(id integer)');
         if (!$createRes) {
             $res = false;
             $this->error("[{$type}] " . 'Could not create test table: ci_test_dummy');
         } else {
             $res = true;
             $this->info("[{$type}] " . 'Successfully created test table: ci_test_dummy');
             $db->execute('DROP table ci_test_dummy');
         }
     }
     return $res;
 }