Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 958 Rev 959
Line 475... Line 475...
475
	
475
	
Line 476... Line 476...
476
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
476
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
477
	
477
	
478
	public function assemblerLaRequete() {
478
	public function assemblerLaRequete() {
479
		$requete = 	' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
479
		$requete = 	' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
480
		.$this->retournerRequeteCondition().' ';
480
		.Informations::retournerRequeteCondition($this->requete_condition).' ';
481
			if ($this->nb_ressources != 1 ) {
481
			if ($this->nb_ressources != 1 ) {
482
				$requete .= $this->delimiterResultatsRequete();
482
				$requete .= $this->delimiterResultatsRequete();
483
		} 
483
		} 
Line 484... Line -...
484
		return $requete;
-
 
485
	}
-
 
486
	
-
 
487
	public function calculerTotalResultat() {
-
 
488
		$requete = 'SELECT count(*) as nombre FROM '.$this->table.' '.$this->retournerRequeteCondition();
-
 
489
		$res = $this->getBdd()->recuperer($requete);
-
 
490
		if ($res) {
-
 
491
			$this->total_resultat = $res['nombre'];
-
 
492
		} else {
-
 
493
			$this->total_resultat = 0;
-
 
494
			$e = 'Données introuvables dans la base';
-
 
495
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
-
 
496
		}
484
		return $requete;
497
	}
485
	}
498
	
-
 
499
	public function delimiterResultatsRequete() {
-
 
500
		$this->calculerTotalResultat();
-
 
501
		$requete_limite = '';
-
 
502
		if ($this->limite_requete['limite'] != '*') {
486
	
503
			if ( ($this->limite_requete['depart'] <=  $this->total_resultat)){
-
 
504
				if (($this->limite_requete['limite'] + $this->limite_requete['depart'] )
-
 
505
				< $this->total_resultat  ){
-
 
506
					$requete_limite = 'LIMIT '.$this->limite_requete['depart'].', '
-
 
507
					.$this->limite_requete['limite'];
-
 
508
				}
-
 
509
			} else {
-
 
510
				$e = "Erreur : la valeur pour le paramètre navigation.départ est supérieure".
-
 
511
									" au nombre total de résultats.";
-
 
512
				throw new Exception($e, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
487
	public function delimiterResultatsRequete() {
513
			}
-
 
514
		}
-
 
515
		return $requete_limite;
-
 
516
	}
-
 
517
	
-
 
518
	
488
		$this->total_resultat = self::calculerTotalResultat(
519
	
489
            $this->getBdd(),
520
	public  function retournerRequeteCondition() {
490
            $this->table,
521
		$condition = '';
-
 
522
		if (empty($this->requete_condition) == false) {
-
 
523
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
-
 
Line -... Line 491...
-
 
491
            Array(),
-
 
492
            $this->requete_condition);
-
 
493
		if ($this->limite_requete['limite'] == '*') return '';
-
 
494
 
-
 
495
        if ( ($this->limite_requete['depart'] >  $this->total_resultat)) {
Line -... Line 496...
-
 
496
            throw new Exception(
-
 
497
                "Erreur : la valeur pour le paramètre navigation.départ est supérieure au nombre total de résultats.",
-
 
498
                RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
-
 
499
        }
-
 
500
 
524
		}
501
        if (($this->limite_requete['limite'] + $this->limite_requete['depart'] ) < $this->total_resultat) {
525
		return $condition;
502
            return 'LIMIT '.$this->limite_requete['depart'].', ' .$this->limite_requete['limite'];
526
	}
-
 
527
 
503
        }