From bc2dd619e0bf6faf219d1c88d3152ca0d2f25ff4 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Thu, 25 Feb 2010 12:30:09 +0100 Subject: [PATCH] Global function for querying the database --- lib/general.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/general.php b/lib/general.php index c296728..fa250f8 100644 --- a/lib/general.php +++ b/lib/general.php @@ -42,6 +42,19 @@ function connect_db() pg_connect($dsn); } +function query_db($sql) +{ + $sth = pg_query($sql); + + if ($sth === false) return false; + + $result = array(); + while ($row = pg_fetch_assoc($sth)) + $result[] = $row; + + return $result; +} + function load_js($jsfiles, $jscode) { $ret = ''; -- 2.20.1