用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3559|回复: 4
收起左侧

[HELP] 求问高手,怎样实现与oracle数据库的链接啊

[复制链接]
发表于 2011-4-15 14:36:17 | 显示全部楼层 |阅读模式
我看了前面发的一些帖子,按照上面的方法改了下代码,但是报错,我是新手,请各位前辈帮帮忙,先谢谢大家了
这是database.php中的代码
$db['default']['hostname'] = "127.0.0.1/";
$db['default']['username'] = "username";
$db['default']['password'] = "pwd";
$db['default']['database'] = "orcl";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
这是database/drivers/oci8/oci8_driver.php中修改的 _set_stmt_id方法的代码
function _set_stmt_id($sql)
{
        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));
}
页面报的错误是
A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS - assumed 'OCI_COMMIT_ON_SUCCESS'

Filename: database/DB.php

Line Number: 133
请高手帮帮忙,这是哪的问题啊?
发表于 2011-4-23 15:35:00 | 显示全部楼层
$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.50)(PORT=1521))(CONNECT_DATA=(SID=bi)))';

我是用这种方式的
 楼主| 发表于 2011-4-23 17:10:19 | 显示全部楼层
是写在控制层的构造函数里?
发表于 2011-4-23 17:39:01 | 显示全部楼层
写在db的控制文件里
发表于 2012-7-26 16:13:52 | 显示全部楼层
zxjoke 发表于 2011-4-23 15:35
$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.50)(PORT=1521))(CO ...

这是在windows下可以成功,但在linux下,还是报楼主的错。有人知道如何在linux下用CI连oracle吗?

本版积分规则