noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 20/151: Database Ajout d'une fonction pour re


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 20/151: Database Ajout d'une fonction pour retirer une seule ligne
Date: Sat, 4 Feb 2017 17:14:24 +0000 (UTC)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 913d737534af28985013720d5ad20be3fcf44274
Author: Dany De Bontridder <address@hidden>
Date:   Sat Nov 26 20:41:19 2016 +0100

    Database Ajout d'une fonction pour retirer une seule ligne
---
 include/lib/class_database.php |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/include/lib/class_database.php b/include/lib/class_database.php
index c2d1b78..eff5a44 100644
--- a/include/lib/class_database.php
+++ b/include/lib/class_database.php
@@ -589,12 +589,29 @@ class Database
     {
         $r=$this->exec_sql($p_sql, $p_array);
 
-        if (($Max=pg_NumRows($r))==0)
+        if (pg_NumRows($r)==0)
             return array();
         $array=pg_fetch_all($r);
         return $array;
     }
-
+    /**
+     * Returns only one row from a query
+     * @param string $p_sql
+     * @param array $p_array
+     * @return array , idx = column of the table or null if nothing is found
+     * @throws Exception if too many rows are found code 100
+     */
+    function get_row($p_sql,$p_array=NULL) {
+        $array=$this->get_array($p_sql,$p_array);
+        if (empty($array) ) return null;
+        if (count($array)==1) return $array[0];
+        throw new Exception("Database:get_row retourne trop de lignes",100);
+    }
+    /**
+     * @brief Create a sequence
+     * @param string $p_name Sequence Name
+     * @param int $min starting value
+     */
     function create_sequence($p_name, $min=1)
     {
         if ($min<1)



reply via email to

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