Subversion Repositories Applications.gtt

Rev

Rev 10 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 jpm 1
<?php
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 5.1.1                                                                                    |
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of eFlore.                                                                         |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | it under the terms of the GNU General Public License as published by                                 |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id$
24
/**
25
* Classe ProjetCategorie
26
*
27
* Description
28
*
29
*@package eFlore
30
*@subpackage modele
31
//Auteur original :
32
*@version 3
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
34
//Autres auteurs :
35
*@version 4
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
37
*@author        aucun
38
*@copyright     Tela-Botanica 2000-2006
39
*@version       $Revision$ $Date$
40
// +------------------------------------------------------------------------------------------------------+
41
*/
42
 
43
/**
44
* class ProjetCategorie : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
46
*/
47
class ProjetCategorie extends aGttSql {
48
	/*** Constantes : */
48 jpm 49
	const GPC_TOUS = 'PROJETCATEGORIE_TOUS';
10 jpm 50
	const GPC_ID = 'PROJETCATEGORIE_ID';
48 jpm 51
	const GPC_ID_MAX = 'PROJETCATEGORIE_ID_MAX';
52
	const GPC_LIBELLE = 'PROJETCATEGORIE_LIBELLE';
53
 
10 jpm 54
	/*** Attributs : */
55
	private $id_categorie;
56
	private $libelle;
48 jpm 57
 
10 jpm 58
	/*** Aggregations : */
59
 
60
	/*** Constructeur : */
61
	public function __construct($cmd = null, $parametres = null)
62
	{
63
		$this->dao_table_nom = 'gestion_projet_categorie';
64
		$this->dao_correspondance = array(
65
			'gpc_id_categorie'	=> 'id_categorie',
66
			'gpc_libelle'	=> 'libelle');
48 jpm 67
 
10 jpm 68
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
69
		if (!is_null($cmd)) {
70
			$this->consulter($cmd, $parametres, true);
71
		}
72
	}
48 jpm 73
 
10 jpm 74
	/*** Accesseurs : */
75
	// Id Categorie
76
	public function getIdCategorie()
77
	{
78
		return $this->id_categorie;
79
	}
80
	public function setIdCategorie( $ic )
81
	{
82
		$this->id_categorie = $ic;
83
	}
48 jpm 84
 
10 jpm 85
	// Libelle
86
	public function getLibelle()
87
	{
88
		return $this->libelle;
89
	}
90
	public function setLibelle( $l )
91
	{
92
		$this->libelle = $l;
93
	}
48 jpm 94
 
10 jpm 95
	/*** Méthodes : */
96
 
97
	/**
98
	* Consulter la table gestion_projet_categorie.
99
	* @return mixed un tableau d'objets ProjetCategorie s'il y en a plusieurs, l'objet ProjetCategorie s'il y en a 1 seul sinon false.
100
	*/
101
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
102
	{
103
		if (!is_array($parametres)) {
104
			$parametres[0] = $parametres;
105
		}
106
		switch ($cmd) {
48 jpm 107
			case ProjetCategorie::GPC_TOUS:
108
				$requete = 	'SELECT * '.
109
							'FROM gestion_projet_categorie ';
110
				break;
10 jpm 111
			case ProjetCategorie::GPC_ID:
112
				$requete = 	'SELECT * '.
113
							'FROM gestion_projet_categorie '.
114
							'WHERE gpc_id_categorie = '.$parametres[0].' ';
115
				break;
116
			case ProjetCategorie::GPC_ID_MAX:
48 jpm 117
				$requete =	'SELECT MAX(gpc_id_categorie) as gpc_id_categorie '.
10 jpm 118
							'FROM gestion_projet_categorie ';
48 jpm 119
				break;
120
			case ProjetCategorie::GPC_LIBELLE:
121
				$requete =	'SELECT * '.
122
							'FROM gestion_projet_categorie '.
123
							'WHERE gpc_libelle = "'.$parametres[0].'" ';
10 jpm 124
				break;
125
			default :
126
				$message = 'Commande '.$cmd.'inconnue!';
127
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
128
    			trigger_error($e, E_USER_ERROR);
129
		}
48 jpm 130
 
10 jpm 131
		$resultat = $GLOBALS['db']->query($requete);
132
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
133
		$tab_resultat = array();
134
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
135
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
136
		}
48 jpm 137
 
138
		$resultat_nbre = count($tab_resultat);
10 jpm 139
		if ($resultat_nbre > 1) {
140
			return $tab_resultat;
141
		} else if ($resultat_nbre == 1) {
142
			return $tab_resultat[0];
143
		} else if ($resultat_nbre == 0) {
144
			return false;
145
		}
146
	}
48 jpm 147
 
10 jpm 148
	/** Afficher l'objet ProjetCategorie */
149
	function afficherProjetCategorie()
150
	{
151
		echo '<pre>'.print_r($this, true).'</pre>';
152
	}
153
}
154
 
155
/* +--Fin du code ----------------------------------------------------------------------------------------+
156
*
157
* $Log$
158
*
159
* +-- Fin du code ----------------------------------------------------------------------------------------+
160
*/
161
?>