33 lines
685 B
PHP
33 lines
685 B
PHP
|
<?php
|
||
|
|
||
|
require("../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_query($dbh, $query)
|
||
|
or die("Couldn't query database!");
|
||
|
return $result;
|
||
|
}
|
||
|
|
||
|
function db_num_rows($result) {
|
||
|
return pg_num_rows($result);
|
||
|
}
|