Converting MySQL ADOdb PHP applications to DB2 UDB
Active Data Object Database (ADOdb) for PHP is a database abstraction library 
modeled on Microsoft s ADO for building dynamic Web pages with database 
support. A PHP Web application can use this database class library to access 
any supported database
.
 ADOdb supports MySQL, PostgreSQL, Oracle, 
Microsoft SQL Server, Sybase, Informix, Access, FoxPro, Interbase, ODBC, and 
ADO for true cross platform database independence, which means a PHP 
application written for one database can be easily converted to another 
database.
As both MySQL and DB2 UDB are supported by ADOdb for the PHP library, the 
application conversion will be much easier than other incompatible APIs. ADOdb 
architecture is built in such a way that all the database dependant code are 
stored in stub functions, which means you can easily support your database 
specific functionality by changing the stub file. 
So, for using DB2 UDB from your PHP application you need 
adodb db2.inc.php
instead of 
adodb mysql.inc.php
. As ADOdb function calls will remain the same 
for both the databases, the only change you may need is changing some 
database specific formats.
The ADOdb library provides a wrapper around MySQL API for supporting the 
MySQL database and wrapper around DB2 ODBC Driver for DB2 UDB. So, you 
need DB2 ODBC Driver for using ADOdb libraries. 
The MySQL ADOdb PHP application can be ported to DB2 UDB by doing the 
following changes at various levels of the application:
Loading ADOdb driver
Before using the ADOdb library you need to include PHP ADOdb libraries and 
initialize ADOdb variables in your program. ADOdb requires loading of at least 
two files: 
adodb.inc.php
, which contains all the functions used by all database 
classes
adodb .inc.php,
 which contains database specific code
For instance, MySQL code requires the loading of 
adodb mysql.inc.php
, and 
now you need to change it to a 
adodb db2.inc.php
 file. This can be done by 
changing 
ADOLoadCode( mysql )
 to 
ADOLoadCode( db2 )
; this code actually 
makes sure that you load only the required driver. Example 7 30 shows the 
code for initialization and the changes required for DB2 UDB.
Example 7 30   Loading ADOdb driver for MySQL and DB2 UDB
include( /home/itso/adodb/adodb.inc.php ); 
$ADODB_CACHE_DIR =  /home/itso/adodb/cache ; 
 Chapter 7. Application porting 
183






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