ADODB with PHP and oracle

Oracle is the popular commercial database which is being used with the PHP.There are vaious ways to connect to oracle database.ADODB library is one of the fastest way to connect php with the oracle database.It has Has multi-tier design. Simple high-level design for beginners, and also lower-level advanced Oracle functionality.ADODB provide very high speed databse connectivity with catching and fastest database abstaction.It also allow multiple prepare statement.

An example to connect php with oracle using ADODB library is as follows.

include"/path/to/adodb.inc.php";
$db = NewADOConnection("oci8");
$db->Connect($tnsName, "scott", "tiger");

$rs = $db->Execute("select * from emp where empno>:emp order by empno",
array('emp' => 7900));
while ($arr = $rs->FetchRow())
{
print_r($arr);

}
The Execute( ) function returns a recordset object, and you can retrieve the rows returned using $recordset->FetchRow( ).
You can also query the database using the standard Microsoft ADO MoveNext( ) metaphor. The data array for the current row is stored in the fields property of the recordset object, $rs. MoveNext( ) offers the highest performance among all the techniques for iterating through a recordset:

$rs = $db->Execute("select * from emp where empno>:emp", array('emp' => 7900));
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}

For easy pagination support, we provide the SelectLimit function. The following will perform a select query, limiting it to 100 rows, starting from row 201 (row 1 being the 1st row):

$offset = 200; $limitrows = 100;
$rs = $db->SelectLimit('select * from table', $limitrows, $offset);

Caching

You can define a database cache directory using $ADODB_CACHE_DIR, and cache the results of frequently used queries that rarely change. This is particularly useful for SQL with complex where clauses and group-by's and order-by's. It is also good for relieving heavily-loaded database servers.The following example will cache the following select statement for 7200 seconds

$ADODB_CACHE_DIR = '/var/tmp';
$rs = $db->CacheExecute(7200, "select names from allcountries order by 1");
Using Prepare statements

Prepare( ) is for compiling frequently used SQL statement for reuse. For example, suppose we have a large array which needs to be inserted into an Oracle database. The following will result in a massive speedup in query execution (at least 20-40%), as the SQL statement only needs to be compiled once: