Welcome Guest, Not a member yet? Register   Sign In
oracle db integration in codeigniter
#1

[eluser]Unknown[/eluser]
How to integrate oracle database in codeiginter on xamp & ubuntu machienes.

First we have downloaded the Oracle Instant Client, unzip them to C:\Program Files\ so we will be referring to that location for the remainder of these instructions. Next thing we created a new file in that same directory named tnsnames.ora. This is an important configuration file that allows you to create kind of a local reference to a remote Oracle database server. We pasted the following into that new file:
RDF =  (DESCRIPTION =
  (ADDRESS_LIST =
   (ADDRESS = (PROTOCOL = TCP)(HOST = hrdmw01.1800registry.com)(PORT = 1521))
  )
  (CONNECT_DATA =
   (SERVICE_NAME = HRDEVMOB)
  )
 )
To get your PHP scripts talking to the remote Oracle server, you'll use the oci_connect() function. Before that, we enabled support for the oci8 module by removing comment for this below line in php.ini file.
;extension=php_oci8.dll
After this we updated computer's environment variables. First, PATH environment variable so that it has a reference to C:\Program Files\Oracle Instant Client. Then, created a new environment variable named TNS_ADMIN that points to the same directory. This environment variable ensures that PHP will be able to find your tnsnames.ora file when it tries to connect via oci_connect(), so it's important. Once you've set these environment variables correctly, it's probably a good idea to restart the machine your web server is running on. I had to do this before the changes would register (you can easily check your path if you make a call to phpinfo() from a script). However, it might be possible to only restart Apache (or whatever web server you're running), so you might give that a shot first just to see if you're lucky.
At this point, you should be ready to start connecting to the remote Oracle server from your PHP scripts. To make sure, you can run the following script, keeping in mind that the settings should match what you've set in the steps above:
// try connecting to the database
$conn = oci_connect('username', 'password', 'LOCALNAME');
// check for any errors
if (!$conn)
{
 $e = oci_error();
 print htmlentities($e['message']);
 exit;
}
// else there weren't any errors
else
{
 echo 'I am an Oracle mack daddy.';
}

we are getting ORA-17120 tns connection time out error.




Theme © iAndrew 2016 - Forum software by © MyBB