num
num

Reputation: 21

connect codeigniter to database oracle server

i have some problems to connect between codeigniter 3 to database oracle server in other machine

i've tried 3 times to connect like this :

1

$active_group = 'oracle';  
$conn = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = xyz)))";
...
'hostname' => $conn,
'dbdriver' => 'oci8',
...

and get error "You have specified an invalid database connection group (oracle) in your config/database.php file."

2

$active_group = 'default';
$conn = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = xyz)))";
...
'hostname' => $conn,
'dbdriver' => 'oci8',
...

and get error "Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS - assumed 'OCI_COMMIT_ON_SUCCESS' (this will throw an Error in a future version of PHP)" dan "Message: Call to undefined function oci_connect()" "Filename: C:.........\database\drivers\oci8\oci8_driver.php"

3

i change dbdriver to

 'dbdriver' => 'oci8_12c',

and i get error "Invalid DB driver"


any idea how to connect using codeigniter in the different machine?

thank you for your help

Upvotes: 0

Views: 1965

Answers (1)

Ravi Chauhan
Ravi Chauhan

Reputation: 1458

First of check DB driver https://forum.codeigniter.com/thread-56487.html

My database.php for oracle was like this

$tns = "
(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = YOUR_IP)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = YOUR_SID)
    )
  )
       ";
$db['oracle']['hostname'] = $tns;

You used $this->load->database('oracle',true); this should be assigned to a variable as you used 2nd parameter true. like this

$oracle_db=$this->load->database('oracle',true);//connected with oracle
$mysql_db=$this->load->database('default',true);//connected with mysql

Upvotes: 1

Related Questions