Changeset:
        4f5c8d45272a
        
https://sourceforge.net/p/mrbs/hg-code/ci/4f5c8d45272a0731eb8a36f5f502a131ec88ccd7
Author:
        Campbell Morrison <[email protected]>
Date:
        Thu Sep 29 09:45:56 2016 +0100
Log message:

Added exception throwing to sql_query1() and removed some error checking of 
results

diffstat:

 web/Themes/default/header.inc |  4 ----
 web/lib/MRBS/DB.php           |  7 ++++---
 web/search.php                |  5 +----
 3 files changed, 5 insertions(+), 11 deletions(-)

diffs (56 lines):

diff -r 5532bd4936d5 -r 4f5c8d45272a web/Themes/default/header.inc
--- a/web/Themes/default/header.inc     Thu Sep 29 09:16:05 2016 +0100
+++ b/web/Themes/default/header.inc     Thu Sep 29 09:45:56 2016 +0100
@@ -171,10 +171,6 @@
             $sql_params[] = $user;
           }
           $n_outstanding = sql_query1($sql, $sql_params);
-          if ($n_outstanding < 0)
-          {
-            fatal_error(FALSE, get_vocab("fatal_db_error"));
-          }
           echo "<div id=\"n_outstanding\"" .
                (($n_outstanding > 0) ? " class=\"outstanding\"" : '') .
                ">\n";
diff -r 5532bd4936d5 -r 4f5c8d45272a web/lib/MRBS/DB.php
--- a/web/lib/MRBS/DB.php       Thu Sep 29 09:16:05 2016 +0100
+++ b/web/lib/MRBS/DB.php       Thu Sep 29 09:45:56 2016 +0100
@@ -120,10 +120,12 @@
   
   // Execute an SQL query which should return a single non-negative number 
value.
   // This is a lightweight alternative to query(), good for use with count(*)
-  // and similar queries. It returns -1 on error or if the query did not return
+  // and similar queries. 
+  // It returns -1 on error or if the query did not return
   // exactly one value, so error checking is somewhat limited.
   // It also returns -1 if the query returns a single NULL value, such as from
   // a MIN or MAX aggregate function applied over no rows.
+  // Throws a DBException on error.
   function query1($sql, $params = array())
   {
     try
@@ -133,8 +135,7 @@
     }
     catch (PDOException $e)
     {
-      trigger_error($sql . " " . $e->getMessage(), E_USER_WARNING);
-      return -1;
+      throw new DBException($e->getMessage(), 0, $e, $sql, $params);
     }
     
     if (($sth->rowCount() != 1) || ($sth->columnCount() != 1) ||
diff -r 5532bd4936d5 -r 4f5c8d45272a web/search.php
--- a/web/search.php    Thu Sep 29 09:16:05 2016 +0100
+++ b/web/search.php    Thu Sep 29 09:45:56 2016 +0100
@@ -286,10 +286,7 @@
           WHERE $sql_pred";
   $total = sql_query1($sql, $sql_params);
 }
-if ($total < 0)
-{
-  fatal_error(FALSE, get_vocab("fatal_db_error"));
-}
+
 if (($total <= 0) && !$ajax)
 {
   echo "<p id=\"nothing_found\">" . get_vocab("nothing_found") . "</p>\n";

------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to