CI连接到Oracle 11g

时间:2018-12-17 02:05:14

标签: oracle codeigniter

我有与CI连接的database.php

$dbhost = '192.168.1.3';    //IP or server name of my host database
$dbport = '1521';    //Oracle port
$dbname = 'dev';    //TNS Name
$dbConnString = "
  (DESCRIPTION =(ADDRESS_LIST =   (ADDRESS = (PROTOCOL = TCP)(HOST = ". $dbhost .")(PORT = ". $dbport .")))
  (CONNECT_DATA =(SERVICE_NAME = ". $dbname .") ))";


$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = 'abc';
$db['default']['password'] = 'abcpass';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;//FALSE
$db['default']['db_debug'] = TRUE;//FALSE
$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;

但是,如果我运行此程序,则始终显示错误

A Database Error Occurred

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

Filename: C:\xampp\htdocs\reset\system\database\DB_driver.php

Line Number: 124

我该怎么办? php.ini中的oci8已经打开

1 个答案:

答案 0 :(得分:0)

尝试将默认更改为 dev ...,您的代码将是

$db['dev']['hostname'] = $dbConnString;
$db['dev']['username'] = 'abc';
$db['dev']['password'] = 'abcpass';
$db['dev']['database'] = '';
.
.
.