2 // include_once("../interface/globals.php");
4 $sl_conn = 0; // connection object
5 $sl_err = ""; // global error message
8 global $sl_conn, $sl_dbname, $sl_dbuser, $sl_dbpass;
9 $sl_conn = pg_pconnect("dbname=$sl_dbname user=$sl_dbuser password=$sl_dbpass");
10 if (!$sl_conn) die("Failed to connect to SQL-Ledger database.");
15 if ($sl_conn) pg_close($sl_conn);
18 function SLQuery($query) {
19 global $sl_conn, $sl_err;
21 $res = pg_exec($sl_conn, $query);
22 if (!$res || pg_numrows($res) < 0) {
23 $sl_err = pg_errormessage($sl_conn) . ": $query";
24 if (! $sl_err) $sl_err = "Query failed:" + $query;
29 function SLRowCount($res) {
30 return pg_numrows($res);
33 function SLAffectedCount($res) {
34 return pg_affected_rows($res);
37 function SLGetRow($res, $rownum) {
38 return pg_fetch_array($res, $rownum, PGSQL_ASSOC);
41 function SLQueryValue($query) {
42 $res = SLQuery($query);
43 if (! $sl_err && SLRowCount($res) > 0) {
44 $tmp = pg_fetch_array($res, 0);
50 function SLFreeResult($res) {