Revision: 6471
Updated Code
at May 22, 2008 11:27 by mikegreen
Updated Code
<?php // import PEAR DB libraries. require_once("DB.php"); // Connects to database, returns PEAR DB Object. function connect() { $db =& DB::connect("mysql://user:password@host/database"); if(DB::isError($db)) { die($db->getMessage()); } return $db; } // Returns a list of Arrays containing the results function execute_query($sql) { $conn = connect(); $resultset = $conn->query($sql); if(PEAR::isError($resultset)) { die("Error: " . $resultset->getError()); } $results = Array(); while($row =& $resultset->fetchRow(DB_FETCHMODE_ASSOC)) { $results[] = $row; } $conn->disconnect(); return $results; } ?>
Revision: 6470
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 22, 2008 11:26 by mikegreen
Initial Code
<?php // import PEAR DB libraries. require_once("DB.php"); // Connects to database, returns PEAR DB Object. function connect() { $db =& DB::connect("pgsql://user:password@host/database"); if(DB::isError($db)) { die($db->getMessage()); } return $db; } // Returns a list of Arrays containing the results function execute_query($sql) { $conn = connect(); $resultset = $conn->query($sql); if(PEAR::isError($resultset)) { die("Error: " . $resultset->getError()); } $results = Array(); while($row =& $resultset->fetchRow(DB_FETCHMODE_ASSOC)) { $results[] = $row; } $conn->disconnect(); return $results; } ?>
Initial URL
Initial Description
Initial Title
PEAR::DB MySQL Functions
Initial Tags
mysql, database
Initial Language
PHP