PHP provides two extension modules with which we can connect to Oracle:
- The normal Oracle functions (ORA); and
- the Oracle Call-Interface functions (OCI).
OCI is frequently used. ORA doesn’t include support for CLOBs, BLOBs, BFILEs, ROWIDs, etc.
Here is a sample PHP script that uses OCI Extension module to connect Oracle.
<?php
$dbuser = “username”;
$dbpass = “password”;
$dbserver = “server”;
$c=OCILogon($dbuser, $dbpass, $dbserver);
if (!$c) {
$err = OCIError();
echo “Oracle Connect Error ” . $err[text];
}
OCILogoff($c);
?>
The following program fetches data from Oracle database using OCI :
<?php
$dbuser = “username”;
$dbpass = “password”;
$dbserver = “server”;
$c=OCILogon($dbuser, $dbpass, $dbserver);
if (!$c) {
$err = OCIError();
echo “Oracle Connect Error ” . $err[text];
}
$query =”SELECT * from student_details”;
$res= OCIParse($c,$query);
OCI_Execute($res, OCI_DEFAULT);
while(OCIFetch($res)){
$student_id = OCIResult($res, “STUDENT_ID”);
echo “Student Id” . $student_id;
}
OCILogoff($c);
?>
For more information , visit the following url:
August 14, 2008 at 10:13 am
This is informative blog for PHP+Oracle developers.
Nice! keep it up.
Mayank
August 14, 2008 at 10:45 am
Thanks Mayank!!!
September 24, 2008 at 5:21 am
Hi Shree, Come online. Keep in touch.
-Pathi