我遇到ActiveRecords的问题 - CI为表名添加括号 - 所以oracle会返回错误。
以下是一些如何修复它的信息:)
首先配置数据库
我的旧dns配置看起来像这样
$dsn = array(
'phptype' => 'oci8',
'hostspec' => '192.xx.215.xx',
'service' => 'yyyyy',
'port' => '1521',
'username' => 'zzzzz',
'password' => 'aaaaa'
);
所以我在application\config\database.php
添加了这个:
$db['oracle']['hostname'] = "192.xx.215.xx/yyyyy";
$db['oracle']['username'] = "zzzzz";
$db['oracle']['password'] = "ttttt";
$db['oracle']['database'] = "dbname.table";
$db['oracle']['dbdriver'] = "oci8";
$db['oracle']['dbprefix'] = "";
$db['oracle']['pconnect'] = FALSE; //must be false
$db['oracle']['db_debug'] = TRUE;
$db['oracle']['cache_on'] = FALSE;
$db['oracle']['cachedir'] = "";
$db['oracle']['char_set'] = "utf8";
$db['oracle']['dbcollat'] = "utf8_general_ci";
在system\database\drivers\oci8\oci8_driver.php
替换行
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
与
// remove duplicates if the user already included the escape
$str = preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
$str = rtrim($str,'"');
$str = ltrim($str,'"');
$str = str_replace('"."', '.', $str);
return $str;
现在我的模特你可以打电话
$this->oracle = $this->load->database('oracle', TRUE);
现在Oracle和Ci应该有效! :)