diff --git a/include/basis_db.class.php b/include/basis_db.class.php index 9f5bc600c..b8becf340 100644 --- a/include/basis_db.class.php +++ b/include/basis_db.class.php @@ -63,6 +63,7 @@ abstract class db extends basis abstract function db_add_param($var, $type=FHC_STRING, $nullable=true); abstract function db_parse_bool($var); abstract function db_implode4SQL($var); + abstract function db_getResultJSON($result = null); /** diff --git a/include/pgsql.class.php b/include/pgsql.class.php index bc60c47ab..c919eb3ff 100644 --- a/include/pgsql.class.php +++ b/include/pgsql.class.php @@ -126,6 +126,30 @@ class basis_db extends db } } + public function db_getResultJSON($result = null) + { + $rows=array(); + if(is_null($result)) + { + while($r = pg_fetch_assoc($this->db_result)) + $rows[] = $r; + + //print json_encode($rows); + } + else + { + pg_result_seek($result, 0); + //var_dump($result); + while($r = pg_fetch_assoc($result)) + { + $rows[] = $r; + } + + //print json_encode($rows); + } + return json_encode($rows); + } + public function db_last_error() { return pg_last_error();