PEAR Articles
  Home arrow PEAR Articles arrow Page 3 - Installing a PEAR Package
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

Installing a PEAR Package
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-24

    Table of Contents:
  • Installing a PEAR Package
  • Using the installed Packages
  • mdb2 Package
  • Mail Package
  • More Mail!

  • 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


    Installing a PEAR Package - mdb2 Package


    (Page 3 of 5 )


    The next package that we will test is the mdb2 package. Add the following code to a document, save and run it:

    <?php

    require_once("MDB2.php");

    //include 'connx.php';

    // Build a DSN string (Data Source Name)

    // Required by MDB2::connect()

    //$db_driver://$user:$password@$host/$database_name

    $url="mysql://root:pass@localhost/cms";


    $con = MDB2::factory($url);

    if(PEAR::isError($con)) {

    die("Error while connecting : " . $con->getMessage());

    }else{

    echo "Connection with MDB2 was successful";

    }

    ?>

    The setup of the second code block is the same as for PEAR::DB which we used before. The only difference, apart from the names, is that we explicitly define the connection URL (previously DSN):

    $url="mysql://root:pass@localhost/cms";

    Instead of including the connx.php file:

    include 'connx.php';

    We use the factory method to connect to the database:

    $con = MDB2::factory($url);

    then we check for any errors while attempting to connect and write out the appropriate message:

    if(PEAR::isError($con)) {

    die("Error while connecting : " . $con->getMessage());

    }else{

    echo "Connection with MDB2 was successful";

    }

    More PEAR Articles Articles
    More By David Web


       · I have a question regarding PEAR,As a PHP Web Developer I am accustomed to...
     

    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 3 Hosted by Hostway
    Stay green...Green IT