Subversion Repositories Applications.gtt

Rev

Rev 67 | Rev 71 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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