PEAR Articles

  Home arrow PEAR Articles arrow Page 2 - Database Abstraction with MDB2 from PE...
PEAR ARTICLES

Database Abstraction with MDB2 from PEAR
By: Chris Moyer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2008-07-16

    Table of Contents:
  • Database Abstraction with MDB2 from PEAR
  • Getting Started
  • Basic Usage
  • Prepared Statements

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    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

    More PEAR Articles Articles
    More By Chris Moyer

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap