Codeigniter version 1.6.3
Oracle version 10.2.0.4 use oci8
遇到這個 error :
Message: ocifetchinto() expects parameter 1 to be resource, null given
// 這個檔 \system\database\DB_driver.php 改成..
// $RES->num_rows = $RES->num_rows();
if ($this->dbdriver == 'oci8')
{
$RES->stmt_id = $this->stmt_id;
$RES->curs_id = NULL;
$RES->limit_used = $this->limit_used;
}
$RES->num_rows = $RES->num_rows();
解決沒有使用 UTF8 的問題
// 這個檔 \system\database\drivers\oci8\oci8_driver.php
// 改兩個地方:
function db_connect() 的
return @ocilogon($this->username, $this->password, $this->hostname,$this->char_set);
db_pconnect() 的
return @ociplogon($this->username, $this->password, $this->hostname,$this->char_set);
codeigniter 的連線設定
$db['default']['hostname'] = '//172.20.10.6/DB1';
$db['default']['username'] = "scott";
$db['default']['password'] = "*****";
$db['default']['database'] = "DB1";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = TRUE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
相關聯結:
http://download.oracle.com/docs/cd/B25329_01/doc/install.102/b25144/toc.htm#BABBGFIC
codeigniter 的 oracle driver 問題還不少, 同一隻程式第二個 sql select 的結果跟第一個一樣…
要改
/system/database/drivers/oci8/oci8_driver.php
的159行
if ( ! is_resource($this->stmt_id))
{
$this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
}
改成
$this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
就夠了.