Welcome Guest, Not a member yet? Register   Sign In
[info] Tweak Oracle Connection
#1

[eluser]Subekti Pranoto[/eluser]
Dear all, i have tested CI with the environment:
CI 1.5.4
oracle 9i R2

---------------------------------------------------------------------------------
File /system/application/config/database.php

//-------------------------------------------------------------------------------
$dbhost = '192.168.0.15'; //IP of my host database
$dbport = '1521'; //Oracle port
$dbname= 'MY_ORCL'; //My database Name

$dbConnString = "
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ". $dbhost .")(PORT = ". $dbport ."))
)
(CONNECT_DATA =
(SERVICE_NAME = ". $dbname .")
))
";
//--------------------------------------------------------------------------------

$active_group = "default";

$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = "MY_USER";
$db['default']['password'] = "MY_PASSWORD";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

---------------------------------------------------------------------------------

I tested this because i can't connect directly to my 9i oracle database. with this tweak, now i can connect easyly. hope this help.
#2

[eluser]Derek Allard[/eluser]
Thanks Subekti. Expanding support with other databases is something we're eager to tackle - appreciate this. If you notice anything further please post back here.
#3

[eluser]Peter Ivanov[/eluser]
hey thanks

i am fighting with oracle too Smile
#4

[eluser]blackarma[/eluser]
Wanna use oracle and PHP together (with or without CI) ?

http://www.oracle.com/technology/tech/ph...manual.pdf
http://www.oracle.com/technology/tech/php/index.html

In your exemple you have to use your tweak because your tnsnames.ora file is not set for your DB connexion.
See page 98-99 of the underground manual for the different ways to connect to Oracle.
#5

[eluser]Subekti Pranoto[/eluser]
dear blackarma,

thank you for your links.

have you ever used CI with oracle 9i r2 as i stated. if not, please try it first...

here is my TNSNAMES.ORA
-----------------------------
ORADB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.15)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = MY_ORCL)
)
)
-----------------------------

i have tested that i used params like this:
$db[’default’][’hostname’] = "192.168.0.15";
$db[’default’][’username’] = “MY_USER”;
$db[’default’][’password’] = “MY_PASSWORD”;
$db[’default’][’database’] = “ORADB”;
$db[’default’][’dbdriver’] = “oci8”;
$db[’default’][’dbprefix’] = “”;
$db[’default’][’active_r’] = TRUE;
$db[’default’][’pconnect’] = TRUE;
$db[’default’][’db_debug’] = TRUE;
$db[’default’][’cache_on’] = FALSE;
$db[’default’][’cachedir’] = “”;

in oracle 9i, it is not working. in 10g, it is working fine.
#6

[eluser]tjmthome[/eluser]
Hey, thanks for the tweak. It works

Im sure you saved me hours :cheese:
#7

[eluser]kgill[/eluser]
I've never had a problem with tnsnames & connections to oracle (both 9i & 10g) using CI.

Looking at your example the only differences I can see between your setup and mine is that hostname is the name from tnsnames so in your case ORADB not the IP address and the database can be left blank, your username & tnsnames takes care of that.

db['default']['hostname'] = "ORADB";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";




Theme © iAndrew 2016 - Forum software by © MyBB