noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 190/219: Database : get_value throw an error


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 190/219: Database : get_value throw an error if SQL failed
Date: Mon, 18 Dec 2017 13:23:01 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 0e304db73002de1c2933d530503028682005d9df
Author: Dany De Bontridder <address@hidden>
Date:   Sat Dec 9 15:54:01 2017 +0100

    Database : get_value throw an error if SQL failed
---
 include/lib/database.class.php | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/include/lib/database.class.php b/include/lib/database.class.php
index e484713..258bd45 100644
--- a/include/lib/database.class.php
+++ b/include/lib/database.class.php
@@ -561,18 +561,23 @@ class Database
 
     function get_value($p_sql, $p_array=null)
     {
-        $this->ret=$this->exec_sql($p_sql, $p_array);
-        $r=pg_NumRows($this->ret);
-        if ($r==0)
-            return "";
-        if ($r>1)
-        {
-            $array=pg_fetch_all($this->ret);
-            throw new Exception("Attention $p_sql retourne 
".pg_NumRows($this->ret)."  valeurs ".
-            var_export($p_array, true)." values=".var_export($array, true));
-        }
-        $r=pg_fetch_row($this->ret, 0);
-        return $r[0];
+        try {
+            $this->ret=$this->exec_sql($p_sql, $p_array);
+            $r=pg_NumRows($this->ret);
+            if ($r==0)
+                return "";
+            if ($r>1)
+            {
+                $array=pg_fetch_all($this->ret);
+                throw new Exception("Attention $p_sql retourne 
".pg_NumRows($this->ret)."  valeurs ".
+                var_export($p_array, true)." values=".var_export($array, 
true));
+            }
+            $r=pg_fetch_row($this->ret, 0);
+            return $r[0];
+            
+        } catch (Exception $ex) {
+            throw($ex);
+         }
     }
     /**
      * @brief return the number of rows affected by the previous query



reply via email to

[Prev in Thread] Current Thread [Next in Thread]