Changeset:
        5041e5f5208c
        
https://sourceforge.net/p/mrbs/hg-code/ci/5041e5f5208cbafe8b8bf3a2e5daafacb28fd3a6
Author:
        Campbell Morrison <[email protected]>
Date:
        Mon Sep 26 17:41:56 2016 +0100
Log message:

Tidied up error handling slightly

diffstat:

 web/lib/MRBS/DB.php |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (35 lines):

diff -r 3a630812baee -r 5041e5f5208c web/lib/MRBS/DB.php
--- a/web/lib/MRBS/DB.php       Mon Sep 26 17:28:05 2016 +0100
+++ b/web/lib/MRBS/DB.php       Mon Sep 26 17:41:56 2016 +0100
@@ -108,7 +108,7 @@
     }
     catch (PDOException $e)
     {
-      trigger_error($e->getMessage(), E_USER_WARNING);
+      trigger_error($sql . " " . $e->getMessage(), E_USER_WARNING);
       return -1;
     }
   
@@ -124,14 +124,17 @@
   // a MIN or MAX aggregate function applied over no rows.
   function query1($sql, $params = array())
   {
-    $sth = $this->dbh->prepare($sql);
-    if (!$sth)
+    try
     {
-      trigger_error($sql." ".$this->error(), E_USER_WARNING);
+      $sth = $this->dbh->prepare($sql);
+      $sth->execute($params);
+    }
+    catch (PDOException $e)
+    {
+      trigger_error($sql . " " . $e->getMessage(), E_USER_WARNING);
       return -1;
     }
-    $sth->execute($params);
-
+    
     if (($sth->rowCount() != 1) || ($sth->columnCount() != 1) ||
         (($row = $sth->fetch(PDO::FETCH_NUM)) == NULL))
     {

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

Reply via email to