Rev 639 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/** Exemple lancement:* /opt/lampp/bin/php -d memory_limit=3500M cli.php sptb -a chargerTous*/class Sptb extends EfloreScript {public function executer() {// Lancement de l'action demandéetry {$this->initialiserProjet('sptb');$cmd = $this->getParametre('a');switch ($cmd) {case 'chargerTous' :$this->chargerStructureSql();$this->chargerDonnees('especes');$this->chargerDonnees('lois');break;case 'chargerStructureSql' :$this->chargerStructureSql();break;case 'chargerDonnees' :$this->chargerDonnees('especes');$this->chargerDonnees('lois');break;case 'supprimerTous' :$this->supprimerTous();break;default :throw new Exception("Erreur : la commande '$cmd' n'existe pas!");}} catch (Exception $e) {$this->traiterErreur($e->getMessage());}}private function chargerDonnees($type) {$chemin = Config::get('chemins.'.$type);$table = Config::get('tables.'.$type);$requete = "LOAD DATA INFILE '$chemin' "."REPLACE INTO TABLE $table ".'CHARACTER SET utf8 '.'FIELDS '." TERMINATED BY '\t' "." ENCLOSED BY '' "." ESCAPED BY '\\\' ".'IGNORE 1 LINES';$this->getBdd()->requeter($requete);}private function supprimerTous() {$requete = "DROP TABLE IF EXISTS sptb_meta, sptb_especes_v2012, sptb_lois_v2012";$this->getBdd()->requeter($requete);Debug::printr('suppression');}}?>