CodeIgniter - ActiveRecords和Oracle - 配置

时间:2013-06-11 20:32:41

标签: oracle codeigniter activerecord

我遇到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应该有效! :)

0 个答案:

没有答案