/* * These functions build the foundation for accessing the database: * it is a general database abstraction layer suitable for several * databases. Currently, the only supported database is MySQL but * it should be straightforward to port it to any other database: * just adjust the handlers to your needs. */ function db_connect($host, $name, $pass, $base) { mysql_pconnect($host, $name, $pass) or die(mysql_Error()); mysql_select_db($base) or die ("unable to select database"); // NOTE: we are using a persistent connection! } function db_query($query, $debug = false) { // perform query: $qid = mysql_query($query); // debug output (if required): if ($debug) print "
query: ". htmlspecialchars($query) .""; if (!$qid) watchdog("error", "database: ". mysql_error() ."
error message: ". mysql_error() ."