How To Connect PHP with Oracle

PHP is emerging web technology in this era.The main features of PHP is free to use and easy to understand.Oracle is most popular DB in world,so normally we are using mysql connectivity with php but sometimes we need to add connectivity oracle with php. In this tutorial i will describe how to connect you application with oracle database.

There are following steps to need connect oracle with PHP.
Step 1: We need host,username, password and port for connectivity.
[code type=sql]
$oracleConnect = NULL;

$db_test = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=portnumber)) (CONNECT_DATA=(SID=dbi_subroutine)))’;
$oracleConnect = oci_connect(“username”, “pass”, $db_test)
if (!$oracleConnect) {
$e = oci_error();
trigger_error(htmlentities($e[‘message’], ENT_QUOTES), E_USER_ERROR);

Step 2: Now we will use above connection object and fire SQL.
[code type=sql]

'; } oci_free_statement($rs);

I hope its helps to you.