ADOdb: IntroductionTag: adodb, database, database layer Category: PHP Database post: 29 Oct 2007 read: 2,055
You can amaze your client by saying "It's no problem you will use mysql, mssql, oracle, etc. Our web application support all major database without change codes". Wow, it's advantage for your promotion. The magic secret is php ADOdb.
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.
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. We have had successful reports of connecting to Progress and DB2 via ODBC.
Unique Features of ADOdb (from manual):
- Easy for Windows programmers to adapt to because many of the conventions are similar to Microsoft's ADO.
Unlike other PHP database classes which focus only on select statements, we 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. See adodb-session.php.
Now, we try test this library.
- Download from sourceforge.
- Extract zip file to a web directory.
- Open a database manager (ex, phpmyadmin).
- Create a simple database for test (ex, "inventory").
- Create a simple table (ex, "products").
- Now, Try simple test. Write code below. Put in the same directory with folder adodb. Give name "adodbtest.php":
<?php
include('adodb/adodb.inc.php');
$databasetype = 'mysql';
$server = 'localhost';
$user = 'root';
$password = 'r0ot';
$database = 'inventory';
$db = ADONewConnection($databasetype);
$db->debug = true;
$db->Connect($server, $user, $password, $database);
$rs = $db->Execute('select * from products');
print "<pre>";
print_r($rs->GetRows());
print "</pre>";
?>
- Execute that file.
Now, it's time to tell our client... "Don't worry, My web application support your database".
|
|
| Give Your Opinion | Recommend
|