コード例 #1
0
ファイル: mysql.php プロジェクト: bermi/akelos
 public function connect($die_on_error = true)
 {
     parent::connect($die_on_error);
     if (defined('AK_SET_UTF8_ON_MYSQL_CONNECT') && AK_SET_UTF8_ON_MYSQL_CONNECT) {
         if (isset($this->connection->_connectionID)) {
             if (function_exists('mysql_set_charset')) {
                 mysql_set_charset('utf8', $this->connection->_connectionID);
             } else {
                 mysql_query('SET CHARACTER SET "utf8"', $this->connection->_connectionID);
             }
         }
     }
 }
コード例 #2
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;
 }