Exzilla.net
Contact
Home -> Articles -> Checklist to access Oracle Database by using Pear DB
 
Features
Forums
Files
Blogs
Checklist to access Oracle Database by using Pear DB
April 15, 2003
kouprex
Author's Bio | E-Mail
Copyright (C) 2003 exzilla.net

Purpose:
This article will show you the checklist before starting develop your application to access Oracle Database using PEAR DB API.

Attendees:
Developer

Prerequisites:
N/A

Assumption:
PHP_HOME is a directory that you are going to install PHP software such as D:\PHP
ORACLE_HOME is a directory that you are going to install Oracle software such as E:\Oracle\ora92

Details:
We are using following software configurations in this article

1. Apache 1.3.22 (Win32)
2. Oracle Database Server 9.2
3. Oracle Client Software 9.2
4. PHP 4.2.2
5. PEAR DB 1.4b1
6. All software run on MS Windows 2000 professional SP2

Before you are able access Oracle Database via PEAR DB, you have to integrate all software components like Picture 1

Picture1: PHP database abstraction library

This article will show you the checklist before starting develop your application to access Oracle Database using PEAR DB API

The checklist to implement PEAR DB with OCI8 extension

1. Install Apache httpd
2. Install Oracle Client
3. Configure Oracle network
4. Install PHP Engine with OCI8 extension

Please check the above step details from "How to install Apache/PHP for working with Oracle Database on Win32 Platform" article.

Note: This article is tested on php406, apache 1.3222 and Oracle 8.1.7 client but it should work as well with 4.3.x or Oracle 9.x apache 1.3.2x

5. Check your current configuration before going to the next step

Please make sure you can see OCI enable and you can run the following code snippet.
Download this file and save it as PHP program at your web server and run it

Sample file: oci8.php

6. Check your current PEAR DB API from your PHP_HOME

D:\PHP\pear\db.php

If you don't have or would like to get the new update version, please check the screenshot to complete it from our " khwai weblog "

7. Check PEAR API in your "include_path". You can add PEAR API by using directive include_path in phi.ini or ini_set function

Sample include_path directive in php.ini
include_path = ".;D:\PHP\includes;d:\php\pear;E:\www\lib\Smarty"

Sample, how to add PEAR API in you include_path by using ini_set function

ini_set("include_path",ini_get("include_path").":".$_YOUR_DOCUMENT_ROOT."/lib/pear");

8. Make sure you have included the "DB.php" in your PHP Program

require_once('DB.php');

9. Try to run the sample file for testing your complete PEAR DB and Oracle configuration
Download this file and save it as PHP program in you web server and then run it

Sample file: pear-oci8.php


That's it.

10. It's time to start developing your application with PEAR DB http://pear.php.net

Glossary:

PEAR
PEAR is a framework and distribution system for reusable PHP components. [1]

PEAR DB
PEAR DB is a unified API for accessing SQL-databases [1]

OCI8 extension [2]
These functions allow you to access Oracle8 and Oracle7 databases.
It uses the Oracle8 Call-Interface (OCI8). This extension is more flexible than the standard Oracle extension[3].It supports binding of global and local PHP variables to Oracle placeholders, has full LOB, FILE and ROWID support and allows you to use user-supplied define variables.

Note:

Complete Sample code:

  • Sample code for testing oci8 extension enable: oci8.php
  • Sample code for testing PEAR DB with oci8 extension: pear-oci8.php

References:
[1] http://pear.php.net
[2] http://www.php.net/manual/en/ref.oci8.php
[3] http://www.php.net/manual/en/ref.oracle.php

See also:
" http://vulcanonet.com/soft/?pack=pear_tut "
" http://php.weblogs.com/Compare_PEAR_DB_ADOdb "
" http://www.phpbuilder.com/columns/allan20010115.php3 "

Keywords:
Pear DB, Pear, PHP, Oracle, Thai, Checklist, OCI8, Database, Apache, Windows 2000

 
 
{exzilla.net -- e-development QuickStart --}



Copyright (c) 2001-2005 - Exzilla.net -  All Rights Reserved.
Contact Us | Privacy Policy | Terms & Conditions