1 |
<?php |
2 |
|
3 |
/****************************************************************/ |
4 |
|
5 |
/* constants */ |
6 |
$DEBUG = 0; // XXX not used at all? |
7 |
|
8 |
/****************************************************************/ |
9 |
|
10 |
/* database parameters */ |
11 |
#$dsn = 'mysql://libdata:libdatapw@localhost/libdata'; |
12 |
$dsn = 'pgsql://dpavlin@/libdata'; |
13 |
$dsn_options = array( |
14 |
'debug' => 2, |
15 |
'portability' => DB_PORTABILITY_ALL, |
16 |
); |
17 |
|
18 |
/****************************************************************/ |
19 |
|
20 |
/* establish a connection to the database or bailout */ |
21 |
$db =& DB::connect($dsn, $dsn_options); |
22 |
if (DB::isError($db)) { |
23 |
XXX_debug($db->getMessage() ." / ". |
24 |
$db->getUserInfo() . " / ". |
25 |
$db->getDebugInfo()); |
26 |
# XXX remove this! |
27 |
print $db->getDebugInfo(); |
28 |
|
29 |
die($db->getMessage()); |
30 |
} |
31 |
|
32 |
/****************************************************************/ |
33 |
|
34 |
|
35 |
/* some useful functions */ |
36 |
|
37 |
/* return an error message from a failed sql query */ |
38 |
function sql_err ( $p_sql ) { |
39 |
printf ( "ERROR: Query failed.<br>%s<br>%s: %s<br>\n", |
40 |
$p_sql, xx_errno(), xx_error() ); |
41 |
return 1; |
42 |
} |
43 |
|
44 |
/* finish off the html stream and die */ |
45 |
function bailout() { |
46 |
die ( "Bailing Out!<br>\n</body></html>\n" ); |
47 |
} |
48 |
|
49 |
|
50 |
?> |