我遇到了 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 应该可以工作了!:)