Changeset:
        3a630812baee
        
https://sourceforge.net/p/mrbs/hg-code/ci/3a630812baee3bd74c4da150a2892e1616d2ddfc
Author:
        Campbell Morrison <[email protected]>
Date:
        Mon Sep 26 17:28:05 2016 +0100
Log message:

Configured PDO to throw exceptions

diffstat:

 web/lib/MRBS/DB.php |  14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diffs (40 lines):

diff -r 3cf9451777a6 -r 3a630812baee web/lib/MRBS/DB.php
--- a/web/lib/MRBS/DB.php       Mon Sep 26 17:19:05 2016 +0100
+++ b/web/lib/MRBS/DB.php       Mon Sep 26 17:28:05 2016 +0100
@@ -47,7 +47,8 @@
       $this->dbh = new 
PDO(static::DB_DBO_DRIVER.":host=$db_host;port=$db_port;dbname=$db_name",
                            $db_username,
                            $db_password,
-                           array(PDO::ATTR_PERSISTENT => ($persist ? true : 
false)));
+                           array(PDO::ATTR_PERSISTENT => ($persist ? true : 
false),
+                                 PDO::ATTR_ERRMODE    => 
PDO::ERRMODE_EXCEPTION));
       $this->command("SET NAMES 'UTF8'");
     }
     catch (PDOException $e)
@@ -100,8 +101,6 @@
   // Returns -1 on error; use error() to get the error message.
   public function command($sql, $params = array())
   {
-    $ret = -1;
-  
     try
     {
       $sth = $this->dbh->prepare($sql);
@@ -110,15 +109,10 @@
     catch (PDOException $e)
     {
       trigger_error($e->getMessage(), E_USER_WARNING);
-      return $ret;
+      return -1;
     }
   
-    if ($sth)
-    {
-      $ret = $sth->rowCount();
-    }
-  
-    return $ret;
+    return $sth->rowCount();
   }
 
   

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

Reply via email to