Subversion Repositories Applications.referentiel

Compare Revisions

Ignore whitespace Rev 51 → Rev 52

/trunk/bibliotheque/dao/Dao.php
13,6 → 13,8
* @version SVN: $Id$
*/
abstract class Dao {
const ORDRE_ASCENDANT = 'ASC';
const ORDRE_DESCENDANT = 'DESC';
const HTTP_REQUETE_SEPARATEUR = '&';
protected $distinction = '0';
protected $limite_debut = null;
26,6 → 28,16
//+----------------------------------------------------------------------------------------------------------------+
// ACCESSEURS
public function setDistinction($distinct) {
$this->distinction = $distinct;
}
public function getDistinction() {
return $this->distinction;
}
public function viderDistinction() {
$this->distinction = null;
}
public function avoirLimitation() {
$limitation = false;
if (!is_null($this->limite_debut) && !is_null($this->limite_nbre)) {
33,20 → 45,10
}
return $limitation;
}
public function setDistinction($distinct) {
$this->distinction = $distinct;
}
public function getDistinction() {
return $this->distinction;
}
public function setLimitation($limite_debut, $limite_nbre) {
$this->limite_debut = $limite_debut;
$this->limite_nbre = $limite_nbre;
}
public function getLimiteDebut() {
return $this->limite_debut;
}
53,7 → 55,35
public function getLimiteNbre() {
return $this->limite_nbre;
}
public function viderLimite() {
$this->limite_debut = null;
$this->limite_nbre = null;
}
public function addOrdre($champ, $trie = self::ORDRE_ASCENDANT) {
if (!isset($this->ordre[$champ])) {
if (self::ORDRE_ASCENDANT == $trie || self::ORDRE_DESCENDANT == $trie) {
$this->ordre[$champ] = $trie;
} else {
$e = "La valeur pour le trie doit être : {self::ORDRE_ASCENDANT} ou {self::ORDRE_DESCENDANT}.";
trigger_error($e, E_USER_WARNING);
}
} else {
$e = "Le champ $champ existe déjà dans le tableau des ordres.";
trigger_error($e, E_USER_WARNING);
}
}
public function getOrdre() {
$champs = array();
foreach ($this->ordre as $champ => $trie) {
$champs[] = "$champ $trie";
}
return implode(', ', $champs);
}
public function viderOrdre() {
$this->ordre = null;
}
//+----------------------------------------------------------------------------------------------------------------+
// MÉTHODES
105,6 → 135,7
fclose($flux);
}
}
$this->reinitialiser();
return $contenu;
}
116,6 → 147,9
if (! is_null($this->getLimiteNbre())) {
$parametres[] = 'limit='.$this->getLimiteNbre();
}
if (! is_null($this->ordre)) {
$parametres[] = 'orderby='.urlencode($this->getOrdre());
}
if ($this->getDistinction() != 0) {
$parametres[] = 'distinct='.$this->getDistinction();
}
173,4 → 207,10
}
}
}
private function reinitialiser() {
$this->viderDistinction();
$this->viderLimite();
$this->viderOrdre();
}
}