ADODB is a powerful databaseabstraction library for PHP applications. As a developer, one of the most important things to consider when developing a Web application is portability. Given the rapid pace of change in the Web world, it doesn’t do to bind your code too tightly to a specific operating system, RDBMS or programming language; if you do, you’ll find yourself reinventing the wheel every time things change on you (and they will – take my word for it).
PHP’s database access functions are not standardised. This creates a need for a database class library to hide the differences between the different database API’s (encapsulate the differences) so we can easily switch databases. For example, When we use PHP database classes, if we want to execute select query to get data from mysql database, we need to use the mysql_query() function. If we want to execute the same query to get data from MS SQL server, we need to use the mssql_query() function. But the ADODB class library provides a commen function Execute() to execute the same select query in all supported databases($db->Execute(‘select * from tbl_category’)). The ADODB currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access, ADO and ODBC.
The Features of ADOdb
- Unlike other PHP database classes which focus only on select statements, ADODB provide support code to handle inserts and updates which can be adapted to multiple databases quickly. Methods are provided for date handling, string concatenation and string quoting characters for differing databases.
- A metatype system is built in so that we can figure out that types such as CHAR, TEXT and STRING are equivalent in different databases.
- Easy to port because all the database dependant code are stored in stub functions. You do not need to port the core logic of the classes.
- PHP4 session support.
Quick Installation Guide.
- Make sure you are running PHP 4.0.5 or later.
- Download the ADODb class library from here – Download ADODb
- Unpack all the files into a directory accessible by your webserver.
- Create a new datatbase. For this example, I am using mysql database,MySQL Workbench 5.2 and I have created a database called “ecards”. In that database, i am going to create a new table called “tbl_product”. The following is the SQL Query for my database table.
Now access the file from the brower, for example – http://www.example.com/testAdodb.php, you will be able to see all the records from the tbl_product table