2000-06-10 19:08:23 +00:00
|
|
|
<?
|
2000-06-11 13:28:26 +00:00
|
|
|
|
2001-01-06 11:39:43 +00:00
|
|
|
function db_connect($host, $user, $pass, $name) {
|
|
|
|
mysql_pconnect($host, $user, $pass) or die(mysql_Error());
|
|
|
|
mysql_select_db($name) or die ("unable to select database");
|
2000-09-26 07:34:33 +00:00
|
|
|
// NOTE: we are using a persistent connection!
|
|
|
|
}
|
|
|
|
|
2000-06-10 19:08:23 +00:00
|
|
|
function db_query($query, $debug = false) {
|
2000-11-13 08:17:45 +00:00
|
|
|
// perform query:
|
2000-06-10 19:08:23 +00:00
|
|
|
$qid = mysql_query($query);
|
|
|
|
|
2000-11-13 08:17:45 +00:00
|
|
|
// debug output (if required):
|
|
|
|
if ($debug) print "<PRE>query: ". htmlspecialchars($query) ."<BR>error message: ". mysql_error() ."</PRE>";
|
|
|
|
if (!$qid) watchdog("error", "database: ". mysql_error() ."<BR>query: ". htmlspecialchars($query) ."");
|
2001-01-26 13:38:46 +00:00
|
|
|
|
|
|
|
// return result from query:
|
2000-06-10 19:08:23 +00:00
|
|
|
return $qid;
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_fetch_object($qid) {
|
|
|
|
if ($qid) return mysql_fetch_object($qid);
|
|
|
|
}
|
|
|
|
|
2000-06-22 09:08:12 +00:00
|
|
|
function db_num_rows($qid) {
|
|
|
|
if ($qid) return mysql_num_rows($qid);
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_fetch_row($qid) {
|
|
|
|
if ($qid) return mysql_fetch_row($qid);
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_fetch_array($qid) {
|
|
|
|
if ($qid) return mysql_fetch_array($qid);
|
|
|
|
}
|
|
|
|
|
2000-12-30 11:58:14 +00:00
|
|
|
function db_result($qid, $field = 0) {
|
2000-06-22 18:18:06 +00:00
|
|
|
if ($qid) return mysql_result($qid, $field);
|
|
|
|
}
|
|
|
|
|
2001-03-01 21:34:09 +00:00
|
|
|
// Setup database connection:
|
2001-01-06 11:39:43 +00:00
|
|
|
db_connect($db_host, $db_user, $db_pass, $db_name);
|
2000-06-11 13:28:26 +00:00
|
|
|
|
2001-03-01 21:34:09 +00:00
|
|
|
?>
|