PEAR Articles
  Home arrow PEAR Articles arrow Page 2 - Database Abstraction with MDB2 from PE...
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
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 / 6
    2008-07-16

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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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


       · Thanks for taking the time to read this article! It's part of a series covering...
       · last sentence should be$result = $query->execute(array('Chris Moyer'));instead...
     

    PEAR ARTICLES ARTICLES

    - 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
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek