Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 441 → Rev 442

/trunk/scripts/bibliotheque/EfloreCommun.php
New file
0,0 → 1,68
<?php
/**
*
* fonctions
* @author mathilde
*
*/
 
class EfloreCommun {
private $Bdd = null;
private $projetNom = null;
public function initialiserProjet($projetNom) {
$this->projetNom = $projetNom;
$this->chargerConfigDuProjet();
}
//+------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les scripts n'ont pas besoin de s'y connecter.
*/
public function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
//+------------------------------------------------------------------------------------------------------+
// Méthodes communes aux projets d'eFlore
public function chargerConfigDuProjet() {
$fichierIni = $this->getScriptChemin().$this->getProjetNom().'.ini';
if (file_exists($fichierIni)) {
Config::charger($fichierIni);
} else {
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
throw new Exception($m);
}
}
//changée
public function chargerStructureSql($structure_sql) {
$contenuSql = $this->recupererContenu(Config::get($structure_sql));
$this->executerScripSql($contenuSql);
}
public function executerScripSql($sql) {
$requetes = Outils::extraireRequetes($sql);
foreach ($requetes as $requete) {
$this->getBdd()->requeter($requete);
}
}
public function recupererContenu($chemin) {
$contenu = file_get_contents($chemin);
if ($contenu === false){
throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
}
return $contenu;
}
}
?>