Database Abstraction with MDB2 from PEAR - Getting Started
(Page 2 of 4 )
In order to get started with MDB2, you'll need three things: a supported database, the PEAR packages for MDB2 and the PEAR packages for the database you intend to use. Let's walk through these steps.
First, make sure you have a supported database. At present MDB2 provides access layers for MySQL, Postgres, Oracle, Frontbase, Queryism, Firebird, MSSQL and SQLite. Not all of the drivers are supported and maintained at the same level; Frontbase and Firebird both have caveats to their support. Ensure that your database is up and running and that you have valid connection parameters. There's nothing more frustrating that thinking your code is wrong... and later discovering that it was actually the wrong password.
Next, install the PEAR MDB2 package. This is generally as simple as:
> pear install MDB2
Starting to download MDB2-2.4.1.tgz (119,790 bytes)
.....................done: 119,790 bytes
install ok: channel://pear.php.net/MDB2-2.4.1
MDB2: Optional feature fbsql available (Frontbase SQL driver for MDB2)
MDB2: Optional feature ibase available (Interbase/Firebird driver for MDB2)
MDB2: Optional feature mysql available (MySQL driver for MDB2)
MDB2: Optional feature mysqli available (MySQLi driver for MDB2)
MDB2: Optional feature mssql available (MS SQL Server driver for MDB2)
MDB2: Optional feature oci8 available (Oracle driver for MDB2)
MDB2: Optional feature pgsql available (PostgreSQL driver for MDB2)
MDB2: Optional feature querysim available (Querysim driver for MDB2)
MDB2: Optional feature sqlite available (SQLite2 driver for MDB2)
To install use "pear install pear/MDB2#featurename"
As you can see, installation is incredibly simple with a properly set up PEAR distribution. At the time of writing, the latest version of MDB2 is 2.4.1, as shown above.
Finally, as the output show above for the last step hinted, you need to install a driver for you particular database; again, this is quite simple.
> pearl install MDB2#mysql
Replace "mysql" with the appropriate driver for your system
Next: Basic Usage >>
More PEAR Articles Articles
More By Chris Moyer