2003-11-23 21:44:06 +01:00
|
|
|
<?php
|
|
|
|
|
2004-05-10 21:46:56 +02:00
|
|
|
require("/var/local/gvadm/config.php");
|
2003-11-23 21:44:06 +01:00
|
|
|
|
|
|
|
function db_open() {
|
|
|
|
global $config;
|
|
|
|
$dbh = pg_connect("dbname=".$config["db_name"].
|
|
|
|
" host=".$config["db_host"].
|
|
|
|
" user=".$config["db_user"].
|
|
|
|
" password=".$config["db_pass"])
|
|
|
|
or die("Couldn't connect to database!");
|
|
|
|
return $dbh;
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_exec($dbh, $query) {
|
|
|
|
pg_exec($dbh, $query)
|
|
|
|
or die("Couldn't execute query!");
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_close($dbh) {
|
|
|
|
pg_close($dbh)
|
|
|
|
or die("Couldn't close database connection!");
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_query($dbh, $query) {
|
2004-05-10 21:46:56 +02:00
|
|
|
$result = pg_exec($dbh, $query)
|
2003-11-23 21:44:06 +01:00
|
|
|
or die("Couldn't query database!");
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_num_rows($result) {
|
2004-05-10 21:46:56 +02:00
|
|
|
return pg_numrows($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
function db_fetch_array($sth) {
|
|
|
|
return pg_fetch_array($sth);
|
|
|
|
}
|