From 4e651437a8fcfeb58db9ca17449952e3d683640e Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sun, 3 Aug 2003 12:57:21 +0000 Subject: [PATCH] Ajout fonction liste_array --- htdocs/cactioncomm.class.php3 | 74 ++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/htdocs/cactioncomm.class.php3 b/htdocs/cactioncomm.class.php3 index 5cb8517e37e..8109a51afc3 100644 --- a/htdocs/cactioncomm.class.php3 +++ b/htdocs/cactioncomm.class.php3 @@ -1,8 +1,5 @@ - * - * $Id$ - * $Source$ +/* Copyright (C) 2002-2003 Rodolphe Quiedeville * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,36 +15,77 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * $Id$ + * $Source$ + * */ class CActioncomm { var $id; var $libelle; - Function CActioncomm() { - - } + Function CActioncomm($DB=0) + { + $this->db = $DB; + } /* * * * */ - Function fetch($db, $id) { - $sql = "SELECT libelle FROM c_actioncomm WHERE id=$id;"; + Function liste_array() + { + $ga = array(); - if ($db->query($sql) ) { - if ($db->num_rows()) { - $obj = $db->fetch_object(0); + $sql = "SELECT id, libelle FROM c_actioncomm"; + $sql .= " ORDER BY id"; - $this->id = $id; - $this->libelle = $obj->libelle; + if ($this->db->query($sql) ) + { + $nump = $this->db->num_rows(); - $db->free(); + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($i); + + $ga[$obj->id] = $obj->libelle; + $i++; + } + } + return $ga; } - } else { - print $db->error(); - } + else + { + print $this->db->error(); + } } + + + Function fetch($db, $id) + { + + $sql = "SELECT libelle FROM c_actioncomm WHERE id=$id;"; + + if ($db->query($sql) ) + { + if ($db->num_rows()) + { + $obj = $db->fetch_object(0); + + $this->id = $id; + $this->libelle = $obj->libelle; + + $db->free(); + } + } + else + { + print $db->error(); + } + } } ?>