noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 104/151: Improve Noalyss_SQL : add set and ge


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 104/151: Improve Noalyss_SQL : add set and get
Date: Sat, 4 Feb 2017 17:14:32 +0000 (UTC)

sparkyx pushed a commit to branch master
in repository noalyss.

commit c320ed75a4d198dc02dc77476d677c5392fc67d8
Author: Rachel <address@hidden>
Date:   Thu Jan 5 15:02:59 2017 +0100

    Improve Noalyss_SQL : add set and get
    
    Signed-off-by: Dany De Bontridder <address@hidden>
---
 include/database/class_noalyss_sql.php |   39 +++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/include/database/class_noalyss_sql.php 
b/include/database/class_noalyss_sql.php
index 1844f19..21babcd 100644
--- a/include/database/class_noalyss_sql.php
+++ b/include/database/class_noalyss_sql.php
@@ -77,7 +77,10 @@ abstract class Noalyss_SQL
         $this->cn=$p_cn;
         $pk=$this->primary_key;
         $this->$pk=$p_id;
-
+       // check that the definition is correct
+       if (count($this->name) != count($this->type) {
+               throw new Exception (__FILE__." $this->table Cannot 
instantiate");
+       }
         /* Initialize an empty object */
         foreach ($this->name as $key)
         {
@@ -100,7 +103,37 @@ abstract class Noalyss_SQL
         else
             $this->update();
     }
+    /**
+     address@hidden get the value thanks the colum name and not the alias 
(name). 
+     address@hidden getp
+     */
+    public function get($p_string)
+    {
+        if (array_key_exists($p_string, $this->type)) {
+            $idx=$this->type[$p_string];
+            return $this->$idx;
+        }
+        else
+            throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur 
attribut inexistant '.$p_string);
+    }
 
+    /**
+     address@hidden set the value thanks the colum name and not the alias 
(name)
+     address@hidden setp
+     */
+    public function set($p_string, $p_value)
+    {
+        if (array_key_exists($p_string, $this->type))    {
+            $idx=$this->type[$p_string];
+            $this->$idx=$p_value;
+        }        else
+            throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur 
attribut inexistant '.$p_string);
+    }
+
+    /**
+     address@hidden set the value thanks the alias name instead of the colum 
name 
+     address@hidden get
+     */
     public function getp($p_string)
     {
         if (array_key_exists($p_string, $this->name)) {
@@ -111,6 +144,10 @@ abstract class Noalyss_SQL
             throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur 
attribut inexistant '.$p_string);
     }
 
+    /**
+     address@hidden set the value thanks the alias name instead of the colum 
name 
+     address@hidden set
+     */
     public function setp($p_string, $p_value)
     {
         if (array_key_exists($p_string, $this->name))    {



reply via email to

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