Just like ADOdb, it enables the PHP application to be written once and run with 
minor changes for various database engines such as MySQL, Oracle, 
PostgreSQL, or DB2 UDB.
To provide database abstraction features, PEAR DB uses an object oriented 
methodology such as classes and objects. For doing so it uses three files:
DB.php
This class contains implementation of the DB class, which creates database 
connection objects.
common.php
This class contains generic code for all the database specific implementation 
of the database access methods. All the drivers inherit and overload this 
code.
.php
This file contains database specific implementation of the access code. This 
class is also called the driver class and is used by PHP applications. In case 
of MySQL, the driver file is 
mysql.php,
 whereas in the case of DB2 it is 
odbc.php
.
The way PEAR DB provides its services for a DB2 UDB application and MySQL 
application is quite different. In MySQL PEAR DB uses the currently existing 
extension for MySQL database, whereas PEAR DB does not provide any 
extension for connecting to DB2 UDB, so the ODBC extension is used for the 
DB2 UDB connection.
The PHP application that uses PEAR DB for database connection generally 
performs the following steps:
Include PEAR DB objects
As discussed before PEAR DB requires three files 
DB.php
, 
common.php
 and 
.php
 for proper functioning of the PHP application. But you 
need not explicitly include all these files, you just need to include 
DB.php
 and 
its functions will include the required driver depending upon your data source 
name.
So for both MySQL and DB2 UDB the include statements will be same as:
include( /home/itso/php/PEAR/DB.php );
Connect to database
PEAR DB database connection can be established using connect method of 
declared in 
DB.php
. This method requires data source name (DSN) 
containing in connection parameters as input. The DSN is a URL style string 
that consists of the database driver name, the user name, the password, the 
186 
MySQL to DB2 UDB Conversion Guide






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved