PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
MySQL.php driver issue: areequals() function not defined
Goto page Previous  1, 2, 3
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PEAR Forum Forum Index -> General PEAR questions
View previous topic :: View next topic  
Author Message
perpetuallyconfused



Joined: 10 Mar 2008
Posts: 16

PostPosted: Fri Mar 21, 2008 7:47 pm    Post subject: Reply with quote

Mark, once again, you are my savior. Appreciate it.

Here's the final code for my database.php file:

Code:
<?php
// reference the PEAR DB library
require_once 'MDB2.php';

// class providing generic data access functionality
class DbManager
{
   public $db;
   // open database connection in the constructor
   function __construct($connectionString)
   {
      $this->db = MDB2::connect($connectionString, USE_PERSISTENT_CONNECTIONS);
      if (MDB2::isError($this->db))
         trigger_error($this->db->getMessage(), E_USER_ERROR);
      $this->db->setFetchMode(MDB2_FETCHMODE_ASSOC);
      $this->db->loadModule('Extended', null, false);
   }

// close the connection
public function DbDisconnect()
{
   $this->db->disconnect();
}

// wrapper class for PEAR DB's query() method
public function DbQuery($queryString)
{
   $result = $this->db->query($queryString);
      if (MDB2::isError($result))
         trigger_error($result->getMessage(), E_USER_ERROR);
   return $result;
}

// wrapper class for PEAR DB's getAll() method

public function DbGetAll($queryString)
{
   $result = $this->db->getAll($queryString);
      if (MDB2::isError($result))
         trigger_error($result->getMessage(), E_USER_ERROR);
   return $result;
}

// wrapper class for PEAR DB's getRow() method
public function DbGetRow($queryString)
{
   $result = $this->db->getRow($queryString);
      if (MDB2::isError($result))
         trigger_error($result->getMessage(), E_USER_ERROR);
   return $result;
}

// wrapper class for PEAR DB's getOne() method
public function DbGetOne($queryString)
{
   $result = $this->db->getOne($queryString);
      if (MDB2::isError($result))
         trigger_error($result->getMessage(), E_USER_ERROR);
   return $result;
}
}
?>


Man, this stuff is not easy to try to do.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PEAR Forum Forum Index -> General PEAR questions All times are GMT + 2 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement