Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 349 | 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 bdnt -a chargerTous
*/
class Bdnt extends EfloreScript {

        public function executer() {
                // Lancement de l'action demandée
                try {
                        $this->initialiserProjet('bdnt');

                        $cmd = $this->getParametre('a');
                    switch ($cmd) {
                        case 'chargerTous' :
                                $this->chargerStructureSql();
                                $this->chargerOntologies();
                                break;
                        case 'chargerStructureSql' :
                                $this->chargerStructureSql();
                                break;
                                case 'chargerOntologies' :
                                        $this->chargerOntologies();
                                        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 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 0 LINES';
                $this->getBdd()->requeter($requete);
        }

        private function supprimerTous() {
                $requete = "DROP TABLE IF EXISTS bdnt_meta, bdnt_ontologies_v4_30";
                $this->getBdd()->requeter($requete);
        }
}
?>