PHP function db::query() returns the result index.
authorarjen <arjen>
Wed, 9 Jul 2003 07:22:52 +0000 (07:22 +0000)
committerarjen <arjen>
Wed, 9 Jul 2003 07:22:52 +0000 (07:22 +0000)
PHP function db::num_rows() accepts a result index as argument
  (default = 0 -> use result from the previous query).
New PHP function db::fetch_object().

src/phpclasses/db.postgres.php

index e8e911c..9858fa3 100644 (file)
@@ -62,6 +62,7 @@
        $this->db_result =  pg_exec ($this->db_connection, $inp_sql_query);
         $this->db_row_number = 0;
 
+        return $this->db_result;
     }
 
     function fetch_row() {
      }
     } 
 
-    function num_rows() {
+    function fetch_object($result, $row)
+    {
+       return pg_fetch_object($result, $row);
+    }
+
+    function num_rows($db_result = 0) {
     /* This functions returns the number of rows in a resultset
-     * INPUT     : NONE
+     * INPUT     : Postgres result index (default = internal result)..
      * OUTPUT    : Number of rows (number)
      */
-     return pg_numrows($this->db_result);
+
+     if ($db_result == 0)
+     {
+        //  Default: use result from inside the object.
+
+        $db_result = $this->db_result;
+     }
+     return pg_numrows($db_result);
+
      // 4.2.X return pg_num_rows($this->db_result);
     }