Home > Uncategorized > Connecting PHP with Oracle

Connecting PHP with Oracle

அறிவுச் சுடரேந்து

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);

?>

View original post

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: