PHP & ORACLE

PHP &  ORACLE

Introduction to ORACLE : –  Oracle DB is well known for scalability , reliability and features.It is a leading DB and is available on many platforms.

Oracle Terminology:  

  1. 1.       Databases and Instances :-  Oracle databases store and retrieve data. Each database consists of one or more data files. An Oracle database server  consists of an Oracle database and an Oracle Instance. Whenever an Oracle database server is started , a shared memory region SGA(System Global Area) is allocated and Oracle background processes are started. Combination of background processes and SGA is called an Oracle Instance.   
  2. 2.       Tablespaces :-  Tablespaces are logical unit of data storage made up of one or more datafiles. 
  3. 3.       Schemas:- A Schema is a collection of database objects such as tables and indexes. Typically, a single DB contains multiple schemas. Multiple Application can use same DB without any conflicts by using   different schemas. Instead of using a CREATE DATABASE command for new application , use CREATE USER to create a new schema in the database. 

PHP ORACLE EXTENSIONS

PHP has several extensions that let application use Oracle DB. Database access  and abstract library in each extension of PHP   is fundamentally similar. The differences are in  support for advanced features and programming methodology.

If you want to make full use of Oracle features and need high performance, PHP OCI8 extension  has to be used. PHP OCI8 is a main ORACLE Extension.

If you want database independence , use PHP PDO(data object) or ADOdb extension for database abstraction.

 

PHP Oracle Extensions

1.Oracle (Not recommended)

2.OCI8

3.PDO

4.ODBC

PHP Oracle extensions are written in C  and linked into PHP Binary.

 

 

OCI8 Extension :- OCI8 Extension is recommended extension to use. It is used in PHP 3,4 and 5.

Example:

<?php

$con=oci_connect(‘dbname’,’passwd’,’localhost/XE’);

$s=oci_parse($con,’select * from User’);

oci_execute($s);

While($res=oci_fetch_array($s,OCI_ASSOC)){

echo $res[‘name’];

}

?>

HOW TO GET OCI8 EXTENSION

Bundle Containing OCI8 Location and Current Release
  1. PHP Source Code
http://www.php.net/downloads.phpphp-5.2.7.tar.bz2
  1.  PECL Source Code
http://pecl.php.net/package/oci8oci8-1.3.4.tgz
  1.  Zend Core for Oracle 2.5
http://www.oracle.com/technology/tech/php/zendcore/ZendCoreForOracle-v2.5.0-Linux-x86.tar.gz

ZendCoreforOracle-v.2.5.0-Windows-x86.exe

   

Oracle has cross-version compatibility, that means if PHP OCI8 is linked with Oracle10g  Client Libraries, then it can able to connect with Oracle database  8i,9i,10g,11g. If OCI8 is linked with oracle 11g client libraries then it can able to connect with Oracle9iR2 onwards  .

Full OCI8 functionality may not be available unless Oracle client libraries and database servers are latest version.

OCI8 and Oracle Compatibility Matrix

Software Bundle PHP Version OCI8 VersionIncluded Oracle Client Libraries Usablewith OCI8
PHP Release Source Code Current release is 5.2.7 OCI8 1.2.5 8i, 9i, 10g, 11g
PECL OCI8 Source Code Builds with PHP 4.3.9onwards Latest release isOCI8 1.3.4 9iR2, 10g, 11g
Zend Core for Oracle 2.5 Includes PHP 5.2.5 OCI8 1.2.3 Inbuilt Oracle Database 10g client
       

ORACLE DATABASE XE :-

Oracle database XE (Oracle 10g ) is available on 32-bit Windows and Linux platform.Oracle DatabseXE is available on Oracle network http://otn.oracle.com/xe

Oracle Database XE has a browser based management interface, Oracle Application Express.

Installing Oracle Database XE on Windows

REFER :- http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf

REFERENCE :- http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf

Advertisements

One Response

  1. Hi,

    Very interesting. Thanks for such great article.

    Thanks and regards,
    Gitesh
    http://www.dbametrix.com

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: