PHP database object fetch function reports when an object is not found.
[gnucomo.git] / src / phpclasses / db.postgres.php
index c8e3370..c595069 100644 (file)
@@ -19,6 +19,8 @@
    var $db_row_number;  //The row-number that is currently active
    var $db_result_row;  //Array with in each element a field of the result
 
+   var $last_query;
+
    function db_connect ($connection_string)
    {
 
@@ -82,6 +84,7 @@
           echo "Query error in " . $inp_sql_query . "\n";
        }
        $this->db_row_number = 0;
+       $this->last_query = $inp_sql_query;
 
        return $this->db_result;
     }
 
     function fetch_object($result, $row)
     {
-       return pg_fetch_object($result, $row);
+       $obj = pg_fetch_object($result, $row);
+
+       if ($obj == false)
+       {
+          echo "No object found for row $row of query " . $this->last_query . ".\n";
+       }
+       return $obj;
     }
 
     function num_rows($db_result = 0)