noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 06/06: Database::make_array ajoute un paramè


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 06/06: Database::make_array ajoute un paramètre dans le cas où le SQL admet une condition
Date: Thu, 11 Sep 2014 17:07:13 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 59e76cb5d33af845174d09475c25e541b631273e
Author: Dany De Bontridder <address@hidden>
Date:   Tue Sep 9 22:23:51 2014 +0200

    Database::make_array ajoute un paramètre dans le cas où le
    SQL admet une condition
---
 include/adm.inc.php              |    4 ++--
 include/ajax_add_menu.php        |    8 ++++----
 include/ajax_get_menu_detail.php |    4 ++--
 include/bank.inc.php             |    4 ++--
 include/class_database.php       |   35 ++++++++++++++++++-----------------
 include/class_iselect.php        |    1 +
 6 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/include/adm.inc.php b/include/adm.inc.php
index ca7fe66..6829fe4 100644
--- a/include/adm.inc.php
+++ b/include/adm.inc.php
@@ -83,8 +83,8 @@ if ( $low_action == "list" )
        echo HtmlInput::request_to_hidden(array('ac'));
     $sel_card=new ISelect('cat');
     $sel_card->value=$cn->make_array('select fd_id, fd_label from fiche_def '.
-                                     ' where  frd_id='.FICHE_TYPE_ADM_TAX.
-                                     ' order by fd_label ',1);
+                                     ' where  frd_id=$1 '.
+                                     ' order by fd_label 
',1,array(FICHE_TYPE_ADM_TAX));
     $sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1;
     $sel_card->javascript=' onchange="submit(this);"';
     echo _('Catégorie :').$sel_card->input();
diff --git a/include/ajax_add_menu.php b/include/ajax_add_menu.php
index 5b22fc2..9a73ab4 100644
--- a/include/ajax_add_menu.php
+++ b/include/ajax_add_menu.php
@@ -33,13 +33,13 @@ $ame_code_dep=$cn->make_array("
        menu_ref
        where
        me_file is null and me_javascript is null and me_url is null and 
me_type<>'PR' and me_type <> 'SP'
-       and me_code in (select me_code from profile_menu where 
p_id=".sql_string($p_id).")".
+       and me_code in (select me_code from profile_menu where p_id=$1)".
        "       UNION ALL
                select me_code,me_code||' '||me_menu||' 
'||coalesce(me_description,'') from menu_ref
        where
                me_code='EXT'
        order by 1
-       ",1);
+       ",1,array($p_id));
 $ame_code=$cn->make_array("
 select me_code,me_code||' '||coalesce(me_menu,'')||' 
'||coalesce(me_description,'')
        ||'('|| case when me_type='SP' then 'Special'
@@ -109,9 +109,9 @@ select me_code,me_code||' '||coalesce(me_menu,'')||' 
'||coalesce(me_description,
        from
        menu_ref
        where me_type='PR'
-       and me_code not in (select me_code from profile_menu where 
p_id=".sql_string($p_id).")
+       and me_code not in (select me_code from profile_menu where p_id=$1)
        order by 1
-       ");
+       ",0,array($p_id));
 
 $me_code=new ISelect('me_code');
 $me_code->value=$ame_code;
diff --git a/include/ajax_get_menu_detail.php b/include/ajax_get_menu_detail.php
index c3e9100..b8f2562 100644
--- a/include/ajax_get_menu_detail.php
+++ b/include/ajax_get_menu_detail.php
@@ -34,13 +34,13 @@ $ame_code_dep=$cn->make_array("
        menu_ref
        where
        me_file is null and me_javascript is null and me_url is null and 
me_type<>'PR' and me_type <> 'SP'
-       and me_code in (select me_code from profile_menu where 
p_id=".sql_string($profile).")".
+       and me_code in (select me_code from profile_menu where p_id=$1)".
        "       UNION ALL
                select me_code,me_code||' '||me_menu||' 
'||coalesce(me_description,'') from menu_ref
        where
                me_code='EXT'
        order by 1
-       ",1);
+       ",1,array($profile));
 $a_type=$cn->make_array("select pm_type,pm_desc from profile_menu_type",1);
 
 $array=$cn->get_array("select 
p_id,pm_id,me_code,me_code_dep,p_order,p_type_display,pm_default
diff --git a/include/bank.inc.php b/include/bank.inc.php
index c76d745..643c1e9 100644
--- a/include/bank.inc.php
+++ b/include/bank.inc.php
@@ -76,8 +76,8 @@ if ( $low_action == "list" )
             $a);
     $sel_card=new ISelect('cat');
     $sel_card->value=$cn->make_array('select fd_id, fd_label from fiche_def '.
-                                     ' where  frd_id='.FICHE_TYPE_FIN.
-                                     ' order by fd_label ',1);
+                                     ' where  frd_id=$1'.
+                                     ' order by fd_label 
',1,array(FICHE_TYPE_FIN));
     $sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1;
     $sel_card->javascript=' onchange="submit(this);"';
     echo _('Catégorie :').$sel_card->input();
diff --git a/include/class_database.php b/include/class_database.php
index 4870717..0c4c9b6 100644
--- a/include/class_database.php
+++ b/include/class_database.php
@@ -711,42 +711,43 @@ class Database
     }
 
     /**
-     * \brief make a array with the sql
+     * \brief make a array with the sql.
      *
      * \param $p_sql  sql statement, only the first two column will be 
returned in
      *  an array. The first col. is the label and the second the value
      *  \param $p_null if the array start with a null value
+     *  \param $p_array is the array with the bind value
      * \note this function is used with ISelect when it is needed to have a 
list of
-     * options
+     * options.
      * \return: a double array like
       \verbatim
       Array
       (
-      [0] => Array
-      (
-      [value] => 1
-      [label] => Marchandise A
-      )
+        [0] => Array
+                (
+                [value] => 1
+                [label] => Marchandise A
+               )
 
       [1] => Array
-      (
-      [value] => 2
-      [label] => Marchandise B
-      )
+            (
+            [value] => 2
+            [label] => Marchandise B
+            )
 
       [2] => Array
-      (
-      [value] => 3
-      [label] => Marchandise C
-      )
+            (
+            [value] => 3
+            [label] => Marchandise C
+            )
       )
       \endverbatim
      * \see ISelect
      */
 
-    function make_array($p_sql, $p_null=0)
+    function make_array($p_sql, $p_null=0,$p_array=null)
     {
-        $a=$this->exec_sql($p_sql);
+        $a=$this->exec_sql($p_sql,$p_array);
         $max=pg_NumRows($a);
         if ($max==0&&$p_null==0)
             return null;
diff --git a/include/class_iselect.php b/include/class_iselect.php
index ae1d11d..0548612 100644
--- a/include/class_iselect.php
+++ b/include/class_iselect.php
@@ -21,6 +21,7 @@
 
 /*!\file
  * \brief Html Input
+ * @see Database::make_array
  */
 require_once('class_html_input.php');
 class ISelect extends HtmlInput



reply via email to

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