1
0
Fork 0
gnuviechadmin-historic/php/tools.php

38 lines
764 B
PHP
Raw Normal View History

<?php
require("/var/local/gvadm/config.php");
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) {
$result = pg_exec($dbh, $query)
or die("Couldn't query database!");
return $result;
}
function db_num_rows($result) {
return pg_numrows($result);
}
function db_fetch_array($sth) {
return pg_fetch_array($sth);
}