blob: 7f3da1a0021b8ecbf9dd69ad7a311c9022c67c0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
// $Id$
require_once 'DB.php';
function db_connect($url) {
global $db_handle;
$db_handle = DB::connect($url);
if (DB::isError($db_handle)) {
die ("Database problem: ". $db_handle->getMessage());
}
$db_handle->setFetchMode(DB_FETCHMODE_ASSOC);
}
function db_query($query, $debug = 0) {
global $db_handle;
$result = $db_handle->query($query);
if ($debug) {
print "<p>query: $query<br />"; // error:". $result->getMessage() ."</p>";
}
if (DB::isError($result)) {
watchdog("error", "database: ". $result->getMessage() ."\nquery: ". htmlspecialchars($query));
}
return $result;
}
function db_fetch_object($result) {
if ($result) {
return $result->fetchRow(DB_FETCHMODE_OBJECT);
}
}
function db_fetch_array($result) {
if ($result) {
return $result->fetchRow(DB_FETCHMODE_ASSOC);
}
}
function db_num_rows($result) {
if ($result) {
return $result->numRows($result);
}
}
function db_result($result, $row = 0) {
if ($result && $result->numRows($result) > $row) {
$tmp = $result->fetchRow(DB_FETCHMODE_ORDERED);
return $tmp[$row];
}
}
function db_error($result) {
global $db_handle;
return DB::isError($db_handle);
}
?>
|