SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: help with PEAR.

  1. #1
    SitePoint Evangelist Fleeters's Avatar
    Join Date
    Jul 2003
    Location
    Dumpsville
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with PEAR.

    Hey All, I am just getting going with PEAR. I did the installation and have installed the MDB2 package.

    How do I start using it in code? how do I include it or require it into my scripts?
    Aaron Smith
    smithaaronlee.net

  2. #2
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     <?php
     
    require_once 'MDB2.php';
    $dsn 'mysql://user:pass@host/db';$mdb2 =& MDB2::factory($dsn);
     
     if (
    PEAR::isError($mdb2)) {
         echo (
    $mdb2->getMessage().' - '.$mdb2->getUserinfo());
     }
     
     
    $query ='SELECT * FROM test';
     
     
    // run the query and get a result handler
     
    $result $mdb2->query($query);
     
     
    // check if the query was executed properly
     
    if (PEAR::isError($result)) {
         echo (
    $result->getMessage().' - '.$result->getUserinfo());
         exit();
     }
     
     
    // lets just get row:0 and free the result
     
    $array $result->fetchRow();
     
    $result->free();
     
    var_dump($array);
     
    ?>
    Hope this helps.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The MDB2 package has some good documentation on the PEAR site:

    http://pear.php.net/manual/en/package.database.mdb2.php

    If you have any specific questions, feel free to ask.
    Reduce or eliminate spam on your sites without CAPTHCAs
    - maybe it is possible: http://formantispam.thekerrs.ca/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •