Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 130 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 jpm 1
<?php
40 jpm 2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php iso6391
4
 * 		-a chargerTous
5
 * Options :
6
 * -t : Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes).
7
*/
74 jpm 8
class Iso6391 extends EfloreScript {
40 jpm 9
 
10
	public function executer() {
11
		// Lancement de l'action demandée
12
		try {
74 jpm 13
			$this->initialiserProjet('iso-639-1');
40 jpm 14
 
15
			$cmd = $this->getParametre('a');
16
		    switch ($cmd) {
17
		    	case 'chargerTous' :
18
		    		$this->chargerStructureSql();
19
		    		$this->chargerIso6391();
20
		    		break;
21
	    		case 'chargerStructureSql' :
22
	    			$this->chargerStructureSql();
23
	    			break;
24
				case 'chargerIso6391' :
25
					$this->chargerIso6391();
26
					break;
27
				case 'test' :
28
					$this->tester();
29
					break;
130 jpm 30
				case 'supprimerTous' :
31
					$this->supprimerTous();
32
					break;
40 jpm 33
				default :
74 jpm 34
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
40 jpm 35
			}
36
		} catch (Exception $e) {
37
			$this->traiterErreur($e->getMessage());
38
		}
39
    }
40
 
41
    private function tester() {
42
    	echo Config::get('test');
43
    }
44
 
45
	private function chargerIso6391() {
46
		$chemin = Config::get('chemins.iso6391');
47
		$table = Config::get('tables.iso6391');
48
		$requete = "LOAD DATA INFILE '$chemin' ".
49
			"REPLACE INTO TABLE $table ".
50
			'CHARACTER SET utf8 '.
51
			'FIELDS '.
52
			"	TERMINATED BY ';' ".
53
			"	ENCLOSED BY '\"' ".
54
			"	ESCAPED BY '\\\' ".
55
			'IGNORE 0 LINES';
74 jpm 56
		$this->getBdd()->requeter($requete);
40 jpm 57
	}
130 jpm 58
 
59
	private function supprimerTous() {
349 jpm 60
		$requete = "DROP TABLE IF EXISTS iso_639_1_meta, iso_639_1_v2002";
130 jpm 61
		$this->getBdd()->requeter($requete);
62
	}
40 jpm 63
}
64
?>