From fb539ee5157f7245e0e752fbc651b044bb46c4bf Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 21 Jul 2004 09:05:53 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20fonction=20pour=20r=E9cup=E9rer?= =?UTF-8?q?=20l'id=20d'un=20d=E9partement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/functions.inc.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index d45b7d740b0..aa048f8a7a8 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1321,4 +1321,38 @@ function initialiser_sel() { $htsalt = '$1$'.creer_pass_aleatoire(); } + +/* + * Retourne le rowid d'un departement pas son code + * + */ +Function departement_rowid($db,$code, $pays_id) +{ + $sql = "SELECT c.rowid FROM ".MAIN_DB_PREFIX."c_departements as c,".MAIN_DB_PREFIX."c_regions as r"; + $sql .= " WHERE c.code_departement=". $code; + $sql .= " AND c.fk_region = r.code_region"; + $sql .= " AND r.fk_pays =".$pays_id; + print $sql . " " . $num; + if ($db->query($sql)) + { + $num = $db->num_rows(); + print $sql . " " . $num; + if ($num) + { + $obj = $db->fetch_object(0); + return $obj->rowid; + } + else + { + return 0; + } + $db->free(); + } + else + { + return 0; + } +} + + ?>