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 ~/web/eflore-projets/scripts/cli.php iso6391
* -a chargerTous
* Options :
* -t : Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes).
*/
class Iso31661 extends EfloreScript {
public function executer() {
// Lancement de l'action demandée
try {
$this->initialiserProjet('iso-3166-1');
$cmd = $this->getParametre('a');
switch ($cmd) {
case 'chargerTous' :
$this->chargerStructureSql();
$this->chargerIso31661();
$this->chargerOntologies();
break;
case 'chargerStructureSql' :
$this->chargerStructureSql();
break;
case 'chargerIso31661' :
$this->chargerIso31661();
break;
case 'chargerOntologies' :
$this->chargerOntologies();
break;
case 'test' :
$this->tester();
break;
default :
$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
}
} catch (Exception $e) {
$this->traiterErreur($e->getMessage());
}
}
private function tester() {
echo Config::get('test');
}
private function chargerIso31661() {
$chemin = Config::get('chemins.iso31661');
$table = Config::get('tables.iso31661');
$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 chargerOntologies() {
$chemin = Config::get('chemins.ontologies');
$table = Config::get('tables.ontologies');
$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);
}
}
?>