plugins are now ok too
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Tue, 28 Dec 2004 17:35:42 +0000 (17:35 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:57 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-162

plugins/function.select_db_table.php
plugins/function.select_nat.php
plugins/insert.getName.php
plugins/insert.getUserName.php

index c5a9d13..b9b948d 100644 (file)
 function select_options($table,$valeur,$champ="text",$pad=false,$where="") {
     global $globals;
     $sql = "SELECT id,$champ FROM $table $where ORDER BY $champ";
-    $result = $globals->db->query($sql);
-
+    $res = $globals->xdb->iterRow($sql);
     $sel = ' selected="selected"';
 
     // on ajoute une entree vide si $pad est vrai
     $html = "";
-    if ($pad)
+    if ($pad) {
        $html.= '<option value="0"'.($valeur==0?$sel:"")."></option>\n";
-    while (list($my_id,$my_text) = mysql_fetch_row($result)) {
+    }
+    while (list($my_id,$my_text) = $res->next()) {
        $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",$my_id,($valeur==$my_id?$sel:""),$my_text);
     }
-    mysql_free_result($result);
     return $html;
 }
 
index aae62aa..c581722 100644 (file)
 function select_nat($valeur,$pad=false) {
     global $globals;
     $sql = "SELECT a2 AS id,IF(nat='',pays,nat) AS text FROM geoloc_pays ORDER BY text";
-    $result = $globals->db->query($sql);
-
+    $res = $globals->xdb->iterRow($sql);
     $sel = ' selected="selected"';
 
     // on ajoute une entree vide si $pad est vrai
     $html = "";
-    if ($pad)
+    if ($pad) {
        $html.= '<option value="0"'.($valeur==0?$sel:"")."></option>\n";
-    while (list($my_id,$my_text) = mysql_fetch_row($result)) {
+    }
+    while (list($my_id,$my_text) = $res->next()) {
        $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",$my_id,($valeur==$my_id?$sel:""),$my_text);
     }
-    mysql_free_result($result);
     return $html;
 }
 
index 82b59fb..a1db78a 100644 (file)
@@ -26,12 +26,8 @@ function smarty_insert_getName()
     if ($uid < 0) {
         return "";
     }
-    $res = $globals->db->query("SELECT prenom FROM auth_user_md5 WHERE user_id=$uid");
-    if (list($prenom) = mysql_fetch_row($res)) {
-       mysql_free_result($res);
-       return $prenom;
-    }
-    return "";
+    $res = $globals->xdb->query("SELECT prenom FROM auth_user_md5 WHERE user_id={?}", $uid);
+    return $res->fetchOneCell();
 }
 
 ?>
index f33c263..c70c54b 100644 (file)
@@ -30,13 +30,8 @@ function smarty_insert_getUsername()
         return "";
     }
 
-    $res = $globals->db->query("SELECT  alias
-                                  FROM  aliases
-                                WHERE  id='$id' AND (type IN ('a_vie','alias') AND FIND_IN_SET('bestalias', flags))");
-    if (list($uname) = mysql_fetch_row($res)) {
-       mysql_free_result($res);
-       return $uname;
-    }
-    return "";
+    $res = $globals->xdb->query("SELECT  alias FROM aliases
+                                  WHERE  id={?} AND (type IN ('a_vie','alias') AND FIND_IN_SET('bestalias', flags))", $id);
+    return $res->fetchOneCell();
 }
 ?>