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. 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. Tablespaces :- Tablespaces are logical unit of data storage made up of one or more datafiles.
- 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
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
Filed under: php stuff | Tagged: ORACLE, php | 1 Comment »