Manuphptech’s Blog

Php to Oracle

Posted by: manuphptech on: April 3, 2009

Oracle is the most popular commercial database used with PHP. There are many ways of accessing Oracle databases in PHP. These include: * The oracle extension * The oci8 extension * PEAR DB library * ADOdb library The wide range of choices is confusing to someone just starting with Oracle and PHP. I will briefly summarize the differences, and show you the advantages of using ADOdb

ADOdb Example

In ADOdb, the above oci8 example querying the emp table could be written as:

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


“;
}

Oracle extension Designed for Oracle 7 or earlier. This is obsolete.
Oci8 extension Despite it’s name, which implies it is only for Oracle 8i, this is the standard method for accessing databases running Oracle 8i, 9i or 10g (and later)

Here is an example of using the oci8 extension to query the emp table of the scott schema with bind parameters:

$conn = OCILogon(“scott”,”tiger”, $tnsName); $stmt = OCIParse($conn,”select * from emp where empno > :emp order by empno”); $emp = 7900; OCIBindByName($stmt, ‘:emp’, $emp); $ok = OCIExecute($stmt); while (OCIFetchInto($stmt,$arr)) { print_r($arr); echo “<hr>”; }

We also have many higher level PHP libraries that allow you to simplify the above code. The most popular are PEAR DB and ADOdb. Here are some of the differences between these libraries

Feature PEAR DB 1.6 ADOdb 4.52
General Style Simple, easy to use. Lacks Oracle specific functionality. Has multi-tier design. Simple high-level design for beginners, and also lower-level advanced Oracle functionality.
Support for Prepare Yes, but only on one statement, as the last prepare overwrites previous prepares. Yes (multiple simultaneous prepare’s allowed)
Support for LOBs No Yes, using update semantics
Support for REF Cursors No Yes
Support for IN Parameters Yes Yes
Support for OUT Parameters No Yes
Schema creation using XML No Yes, including ability to define tablespaces and constraints
Provides database portability features No Yes, has some ability to abstract features that differ between databases such as dates, bind parameters, and data types.
Performance monitoring and tracing No Yes. SQL can be traced and linked to web page it was executed on. Explain plan support included.
Recordset caching for frequently used queries No Yes. Provides great speedups for SQL involving complex where, group-by and order-by clauses.
Popularity Yes, part of PEAR release Yes, many open source projects are using this software, including PostNuke, Xaraya, Mambo, Tiki Wiki.
Speed Medium speed. Very high speed. Fastest database abstraction library available for PHP. Benchmarks are available.
High Speed Extension available No Yes. You can install the optional ADOdb extension, which reimplements the most frequently used parts of ADOdb as fast C code. Note that the source code version of ADOdb runs just fine without this extension, and only makes use of the extension if detected.

ADOdb Example

In ADOdb, the above oci8 example querying the emp table could be written as:

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


“;
}

Source : http://phplens.com/lens/adodb/docs-oracle.htm

Posted by: manuphptech on: March 25, 2009

Syllabus of Php 5 certification

Exam Information

PHP Basics

  • Syntax
  • Operators
  • Variables
  • Constants
  • Control Structures
  • Language Constructs and Functions

Functions

  • Syntax
  • Arguments
  • Variables
  • References
  • Returns
  • Variable Scope

Arrays

  • Enumerated Arrays
  • Associative Arrays
  • Array Iteration
  • Multi-Dimensional Arrays
  • Array Functions
  • SPL

Object Oriented Programming

  • Instantiation
  • Modifiers/Inheritance
  • Interfaces
  • Exceptions
  • Static Methods & Properties
  • Autoload
  • Reflection
  • Type Hinting
  • Class Constants

Strings and Patterns

  • Quoting
  • Matching
  • Extracting
  • Searching
  • Replacing
  • Formatting
  • PCRE

Databases and SQL

  • SQL
  • Joins
  • Analyzing Queries
  • Prepared Statements
  • Transactions

Web Features

  • Sessions
  • Forms
  • GET and POST data
  • Cookies
  • HTTP Headers

Streams and Network Programming

  • Files
  • Reading
  • Writing
  • File System Functions
  • Streams

PHP 4/5 Differences

  • Object Orientation
  • E_STRICT
  • References vs. Object Handles

Design and Theory

  • IDesign Patterns
  • Code Reuse
  • OOP Theory

Tags

Follow

Get every new post delivered to your Inbox.