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

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

Code:
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:

Code:
<?php
    $conn = oci_connect("xxxxxx", "xxxxxx","");
    if (!$conn) {
       echo "Not connected!";
    }
    else
      echo "yahooooooooo!!!!!!!!!!";
    ?>


Result:
yahooooooooo!!!!!!!!!!
#2

[eluser]sojan[/eluser]
Hi How did you solve this
#3

[eluser]Unknown[/eluser]
I solved this by uninstalling the full oracle 11g version and installing the express version of Oracle, it worked with the same settings.
#4

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

Code:
$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/
#5

[eluser]duartix[/eluser]
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