 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Fri Mar 21, 2008 7:47 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|
|