From 0b950a315f7cfe1287ce62e62e5c559b3b8cf980 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 15 Feb 2016 15:03:33 +0000 Subject: [PATCH] authzgroups : Raise an exception if there is a SQL error git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2453 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authzgroups.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/authzgroups.php b/authzgroups.php index 74f1eb8..ba94be5 100644 --- a/authzgroups.php +++ b/authzgroups.php @@ -70,10 +70,17 @@ class authzgroups if ($user !== "cli" && $user !== "root") $st->bindValue (":user", $user); $st->bindValue (":module", $module); - $rc = $st->execute (); - if ($rc === false) + try { - if ($this->dbObject->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE\n"; + $rc = $st->execute (); + if ($rc === false) + throw new Exception ("Can't execute SQL request", 500); + } + catch (Exception $e) + { + if ($this->dbObject->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE". + $e->getMessage()."\n"; + throw new Exception ($e->getMessage(), 500); } $res = array (); while ($d = $st->fetch (PDO::FETCH_ASSOC)) @@ -301,6 +308,12 @@ class authzgroups return TRUE; } + /** Disconnect from the database. Should be only used in the unit tests */ + public function disconnect () + { + $this->dbObject->disconnect (); + } + /** Create the tables in the database to store the datas */ public function createTables () {