PHP – Oracle Connectivity

PHP – Oracle Connectivity

Introductions –

Using PHP we can connect many databases like MySQL, Postgresql, DB2, Oracle and SQL server very easily. Now this article provides the information about database connectivity to Oracle using PHP

PHP Oracle functions allow you to access Oracle 10, Oracle 9, Oracle 8 and Oracle 7 databases using the Oracle Call Interface (OCI). They support binding of PHP variables to Oracle placeholders, have full LOB, FILE and ROWID support, and allow you to use user-supplied define variables.

Configuration part in windows php_oci8.dll is the connectivity dll in windows environment. In Linux we can compile php with oracle module

Once the configuration completes you will be able to see this configuration when you execure –

URL = http://localhost/phpinfo.php





** Basic example to connect ORACLE database and execute query –

root@arunbagul:~# cat /var/www/php_oracle.php

$conn = oci_connect(‘hr’, ‘hr’, ‘orcl’);
if (!$conn) {
$e = oci_error();
print htmlentities($e[‘message’]);


$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e[‘message’]);

$r = oci_execute($stid, OCI_DEFAULT);
if (!$r) {
$e = oci_error($stid);
echo htmlentities($e[‘message’]);

Other way to connect to oracle using simple Oracle functions. But these functions are deprecated. Now a day’s oci8 functions are in used.

Santhosh Tirunahari

Similar Posts:

Leave a Reply

Your email address will not be published.