Welcome Guest, Not a member yet? Register   Sign In
Connect Codeigniter to Oracle 11g

Please help! i can't connect codeigniter to Oracle
I am trying to connect Codeigniter to Oracle 11g, here are my settings

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;

Note: I added the C:\instantclient_11_2 to environment variable to PATH.

oracle port number:
oracle hostname: Home-pc
database name: orcl

Only when I run my CodeIgniter login code it shows this error message:

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

But I can connect to Oracle when I run a simple php code like:

    $conn = oci_connect("xxxxxx", "xxxxxx","");
    if (!$conn) {
       echo "Not connected!";
      echo "yahooooooooo!!!!!!!!!!";


Hi How did you solve this

I solved this by uninstalling the full oracle 11g version and installing the express version of Oracle, it worked with the same settings.

I too had a lot of problems connecting through a Full Oracle Client 11 install.
This is how I did it:

$db['oracle']['username'] = "scott"
$db['oracle']['password'] = "tiger"
$db['oracle']['hostname'] = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = the_name_of_my_host)(PORT = 1521)))(CONNECT_DATA =(SID = my_sid_id)(SERVER = DEDICATED)))"

// $db['oracle']['database'] = 'forget all about this parameter';  // It's not used by the ORACLE driver.

$db['oracle']['dbdriver'] = 'oci8';
$db['oracle']['dbprefix'] = '';
$db['oracle']['pconnect'] = TRUE;
$db['oracle']['db_debug'] = FALSE;
$db['oracle']['cache_on'] = FALSE;
$db['oracle']['cachedir'] = '';
$db['oracle']['char_set'] = 'utf8';
$db['oracle']['dbcollat'] = 'utf8_general_ci';
$db['oracle']['swap_pre'] = '';
$db['oracle']['autoinit'] = TRUE;
$db['oracle']['stricton'] = FALSE;

If you do need to make the connection dynamic (making the database one of the connection parameters) this was the best solution I could find: http://ellislab.com/forums/viewthread/237839/

Sending the full connect string was the only way I could find to connect at that time.

However today we discovered that on a Linux machine connected to a remote database, we had to setup the Apache environment variables in order to get our tnsnames.ora and sqlnet.ora loaded (we needed the last one for LDAP authentication).
Here (look for "TNS_ADMIN", it's at "Enabling the PHP OCI8 Extension on Linux", on step 6): http://www.oracle.com/technetwork/articl...84410.html

As soon as the TNS_ADMIN environment variable is set for the Apache session and pointing to tnsnames.ora, it becomes possible to establish connections to the database by SID, without the need to feed in the whole connection string.

Theme © iAndrew 2016 - Forum software by © MyBB