Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 722 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
710 delphine 1
<?php
2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M cli.php sptba -a chargerTous
4
*/
5
class Nva extends EfloreScript {
6
 
7
	public function executer() {
8
		// Lancement de l'action demandée
9
		try {
10
			$this->initialiserProjet('nva');
11
 
12
			$cmd = $this->getParametre('a');
13
		    switch ($cmd) {
14
		    	case 'chargerTous' :
15
		    		$this->chargerStructureSql();
16
		    		$this->chargerDonnees();
17
		    		break;
18
	    		case 'chargerStructureSql' :
19
	    			$this->chargerStructureSql();
20
	    			break;
21
				case 'chargerDonnees' :
22
		    		$this->chargerDonnees();
23
					break;
24
				case 'supprimerTous' :
25
					$this->supprimerTous();
26
					break;
27
				default :
28
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
29
			}
30
		} catch (Exception $e) {
31
			$this->traiterErreur($e->getMessage());
32
		}
33
    }
34
 
35
	private function chargerDonnees() {
36
		$chemin = Config::get('chemins.nva').Config::get('fichiers.nva');
37
		$table = Config::get('tables.nva');
38
		$requete = "LOAD DATA INFILE '$chemin' ".
39
			"REPLACE INTO TABLE $table ".
40
			'CHARACTER SET utf8 '.
41
			'FIELDS '.
42
			"	TERMINATED BY '\t' ".
43
			"	ENCLOSED BY '' ".
44
			"	ESCAPED BY '\\\' ".
45
			'IGNORE 1 LINES';
46
		$this->getBdd()->requeter($requete);
47
	}
48
 
49
 
50
	private function supprimerTous() {
51
		$requete = "DROP TABLE IF EXISTS nva_meta, nva_v2013_06";
52
		$this->getBdd()->requeter($requete);
53
		Debug::printr('suppression');
54
	}
55
}
56
?>