gpt4 book ai didi

codeigniter - 将 Codeigniter 连接到 Oracle 11g

转载 作者:行者123 更新时间:2023-12-04 15:24:34 25 4
gpt4 key购买 nike

请帮忙!我无法将 codeigniter 连接到 Oracle
我正在尝试将 Codeigniter 连接到 Oracle 11g,这是我的设置

Settings in database.php:

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = "//localhost/";
$db['default']['username'] = 'xxxxxxx';
$db['default']['password'] = 'xxxxxxx';
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

注意:我将 C:\instantclient_11_2 添加到环境变量到 PATH。
oracle port number:
oracle hostname: Home-pc
database name: orcl

只有当我运行我的 CodeIgniter 登录代码时,它才会显示以下错误消息:
A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: D:\xampp\htdocs\ci\system\database\DB_driver.php

Line Number: 124

但是当我运行一个简单的 php 代码时,我可以连接到 Oracle:
<?php
$conn = oci_connect("xxxxxx", "xxxxxx","");
if (!$conn) {
echo "Not connected!";
}
else
echo "yahooooooooo!!!!!!!!!!";
?>

结果:
啊啊啊啊啊!!!!!!!!!

最佳答案

在您的配置的 database.php 中进行以下更改

$active_group = 'default';
$active_record = TRUE;

$tnsname = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))';

$db['default']['hostname'] = $tnsname;
$db['default']['username'] = 'XXXXXX';
$db['default']['password'] = 'XXXXX';
$db['default']['database'] = '';
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

关于codeigniter - 将 Codeigniter 连接到 Oracle 11g,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14012996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com