Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 942 | Rev 964 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 942 Rev 959
Line 24... Line 24...
24
class Informations extends Commun {
24
class Informations extends Commun {
Line 25... Line 25...
25
	
25
	
26
	protected $limite_requete = array( 'depart' => 0, 'limite' => 10);
26
	protected $limite_requete = array( 'depart' => 0, 'limite' => 10);
27
	private $tables;
27
	private $tables;
28
	private $champs_recherches = '*';
28
	private $champs_recherches = '*';
29
	private $requete_jointure = "";
29
	private $requete_jointure = array();
30
	private $requete_condition = "";
30
	private $requete_condition = array();
31
	private $total_resultat;
31
	private $total_resultat;
32
	protected $serviceNom = 'informations';
32
	protected $serviceNom = 'informations';
Line 33... Line 33...
33
	private $masque;
33
	private $masque;
Line 233... Line 233...
233
	
233
	
Line 234... Line 234...
234
	//+-------------------------------------assemblage de requête------------------------------------//
234
	//+-------------------------------------assemblage de requête------------------------------------//
235
	
235
	
-
 
236
	
236
	
237
	public function assemblerLaRequete() {
-
 
238
		$requete = 	' SELECT '.$this->champs_recherches.
237
	public function assemblerLaRequete() {
239
            ' FROM '.$this->tables['index'].' '
238
		$requete = 	' SELECT '.$this->champs_recherches.' FROM '.$this->tables['index'].' '
240
            .self::retournerRequeteJointure($this->requete_jointure).' '
239
		.$this->retournerRequeteJointure().' '.$this->retournerRequeteCondition().
241
            .self::retournerRequeteCondition($this->requete_condition).' '
240
		' '.$this->delimiterResultatsRequete();
242
            .$this->delimiterResultatsRequete();
241
		return $requete;
243
		return $requete;
242
	}
-
 
243
	
-
 
244
	public function retournerRequeteCondition() {
244
	}
245
		$condition = '';
-
 
246
		if ($this->requete_condition !== "") {
-
 
247
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
245
 
Line 248... Line 246...
248
		}
246
	static function retournerRequeteCondition($cond) {
-
 
247
        return $cond ? (' WHERE '.implode(' AND ', $cond)) : '';
249
		return $condition;
248
	}
-
 
249
	
250
	}
250
	
251
	
251
	static function calculerTotalResultat($db, $table, Array $join, Array $cond) {
252
	
252
		$requete = sprintf(
253
	public function calculerTotalResultat() {
-
 
254
		$requete = 'SELECT count(*) as nombre FROM '.$this->tables['index'].' '
253
            'SELECT count(*) as nombre FROM %s %s %s -- %s:%d',
255
		.$this->retournerRequeteJointure().' '.$this->retournerRequeteCondition();
254
            $table,
256
		$res = $this->getBdd()->recuperer($requete);
255
            $join ? implode(' ', $join) : '',
257
		if ($res) {
256
            $cond ? (' WHERE '.implode(' AND ', $cond)) : '',
258
			$this->total_resultat = $res['nombre'];
-
 
259
		} else { 
257
            __FILE__,
Line 260... Line 258...
260
			$this->total_resultat = 0;
258
            __LINE__);
261
			$e = 'Données introuvables dans la base';
259
		$res = $db->recuperer($requete);
-
 
260
		if ($res && $res['nombre']) return $res['nombre'];
-
 
261
        throw new Exception('Données introuvables dans la base', RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
-
 
262
	}
-
 
263
	
262
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
264
	public function delimiterResultatsRequete() {
263
		}
265
		$this->total_resultat = self::calculerTotalResultat(
264
	}
266
            $this->getBdd(),
265
	
267
            $this->tables['index'],
266
	public function delimiterResultatsRequete() {
268
            $this->requete_jointure,
Line 277... Line 279...
277
				throw new Exception($e, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
279
				throw new Exception($e, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
278
			}
280
			}
279
		return $requete_limite;
281
		return $requete_limite;
280
	}
282
	}
Line 281... Line 283...
281
	
283
	
282
	public  function retournerRequeteJointure() {
-
 
283
		$jointure = '';
-
 
284
		if ($this->requete_jointure !== "") {
284
	static function retournerRequeteJointure($join) {
285
			$jointure = implode(' ', $this->requete_jointure);
-
 
286
		}
-
 
287
		return $jointure;
285
        return $join ? implode(' ', $join) : '';
Line 288... Line 286...
288
	}
286
	}
289
	
287