1917 |
aurelien |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Exemple lancement:
|
|
|
5 |
* /opt/lampp/bin/php -d memory_limit=3500M cli.php desontologisation -a unitebase
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
class Desontologisation extends Script {
|
|
|
9 |
|
|
|
10 |
private $bdd = null;
|
|
|
11 |
private $structures = array();
|
|
|
12 |
private $communes = array();
|
|
|
13 |
private $nonTrouvees = array();
|
|
|
14 |
|
|
|
15 |
public function __construct($script_nom, $parametres) {
|
|
|
16 |
parent::__construct($script_nom, $parametres);
|
|
|
17 |
$this->bdd = new Bdd();
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public function executer() {
|
|
|
21 |
try {
|
|
|
22 |
$cmd = $this->getParametre('a');
|
|
|
23 |
switch ($cmd) {
|
|
|
24 |
case "unitebase" :
|
|
|
25 |
$this->desontologiserUniteBase(); break;
|
|
|
26 |
default :
|
|
|
27 |
$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
|
|
|
28 |
}
|
|
|
29 |
} catch (Exception $erreur) {
|
|
|
30 |
$this->traiterErreur($erreur->getMessage());
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
private function desontologiserUniteBase() {
|
|
|
35 |
$requete = "SELECT ccb_id_collection, ccb_truk_unite_base ".
|
|
|
36 |
"FROM coel_collection_botanique ".
|
|
|
37 |
"WHERE ccb_truk_unite_base IS NOT NULL AND ccb_truk_unite_base != ''";
|
|
|
38 |
|
|
|
39 |
$infos_truk = $this->bdd->recupererTous($requete);
|
|
|
40 |
|
|
|
41 |
$resultats_fmt = array();
|
|
|
42 |
|
|
|
43 |
foreach($infos_truk as $truk) {
|
|
|
44 |
|
|
|
45 |
$id_collection = $truk['ccb_id_collection'];
|
|
|
46 |
|
|
|
47 |
// Séparation de chaque catégorie d'unite de truk
|
|
|
48 |
$categories_truk = explode(';;', $truk['ccb_truk_unite_base']);
|
|
|
49 |
// Iteration sur toutes les catégories de truk trouvées
|
|
|
50 |
foreach($categories_truk as $categorie_truk) {
|
|
|
51 |
// extraction du numéro d'ontologie de la liste concernée
|
|
|
52 |
$categorie_truk_unite_infos = explode('##', $categorie_truk);
|
|
|
53 |
// Seules les infos de planche d'herbier nous interessent (donc numéro d'ontologie 2270)
|
|
|
54 |
if($categorie_truk_unite_infos[0] == '2270') {
|
|
|
55 |
$truk_unite_infos = $categorie_truk_unite_infos[1];
|
|
|
56 |
|
|
|
57 |
$truk_unite_infos = explode('||', $truk_unite_infos);
|
|
|
58 |
$nb_planches_herbiers = $truk_unite_infos[0];
|
|
|
59 |
$nb_especes = $truk_unite_infos[5];
|
|
|
60 |
|
|
|
61 |
$resultats_fmt[$id_collection] = array(
|
|
|
62 |
'brut' => $truk_unite_infos,
|
|
|
63 |
'nb_planches_herbier' => $nb_planches_herbiers,
|
|
|
64 |
'nb_especes' => $nb_especes
|
|
|
65 |
);
|
|
|
66 |
|
|
|
67 |
$update = 'UPDATE coel_collection_botanique '.
|
|
|
68 |
'SET '.
|
|
|
69 |
'cccb_nb_planches_herbiers = "'.$nb_planches_herbiers.'", '.
|
|
|
70 |
'cccb_nb_especes = "'.$nb_especes.'" '.
|
|
|
71 |
'WHERE ccb_id_collection = "'.$id_collection.'"';
|
|
|
72 |
|
|
|
73 |
$this->bdd->executer($update);
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
?>
|