Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
/**
|
2 |
/**
|
3 |
*
|
3 |
*
|
4 |
* /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php baseflor/Baseflor_rang_sup_insertion
|
- |
|
5 |
* -a insererDonnees
|
4 |
*
|
6 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
5 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
7 |
*
|
6 |
*
|
8 |
*
|
7 |
*
|
9 |
*/
|
8 |
*/
|
10 |
class BaseflorRangSupInsertion {
|
9 |
class BaseflorRangSupInsertion {
|
Line 18... |
Line 17... |
18 |
private $message;
|
17 |
private $message;
|
19 |
private $outils;
|
18 |
private $outils;
|
20 |
private $nn_courant;
|
19 |
private $nn_courant;
|
21 |
private $nn_superieur;
|
20 |
private $nn_superieur;
|
22 |
private $champs_ecologiques = array();
|
21 |
private $champs_ecologiques = array();
|
- |
|
22 |
private $Bdd;
|
Line 23... |
Line 23... |
23 |
|
23 |
|
24 |
|
24 |
|
- |
|
25 |
public function __construct(Conteneur $conteneur, Bdd $bdd) {
|
25 |
public function __construct(Conteneur $conteneur) {
|
26 |
$this->conteneur = $conteneur;
|
26 |
$this->conteneur = $conteneur;
|
27 |
$this->Bdd = $bdd;
|
27 |
$this->efloreCommun = $conteneur->getEfloreCommun();
|
28 |
$this->efloreCommun = $conteneur->getEfloreCommun();
|
28 |
$this->message = $conteneur->getMessages();
|
29 |
$this->message = $conteneur->getMessages();
|
29 |
$this->outils = $conteneur->getOutils();
|
30 |
$this->outils = $conteneur->getOutils();
|
Line 30... |
Line 31... |
30 |
$this->dossierBase = dirname(__FILE__).'/';
|
31 |
$this->dossierBase = dirname(__FILE__).'/';
|
31 |
}
|
32 |
}
|
32 |
|
33 |
|
33 |
public function insererDonnees(){
|
34 |
public function insererDonnees(){
|
34 |
echo "Chargement de la structure en cours \n" ;
|
35 |
echo "Chargement de la structure en cours \n" ;
|
35 |
$this->efloreCommun->chargerStructureSql('chemins.rang_sup_sql');
|
36 |
$this->efloreCommun->chargerFichierSql('chemins.rang_sup_sql');
|
36 |
echo "Récupération des données de baseflor en cours \n";
|
37 |
echo "Récupération des données de baseflor en cours \n";
|
37 |
$this->recupererDonneesInitiales();
|
38 |
$this->recupererDonneesInitiales();
|
Line 43... |
Line 44... |
43 |
|
44 |
|
44 |
|
45 |
|
45 |
private function insererDonneesRangSup() {
|
46 |
private function insererDonneesRangSup() {
|
46 |
$table = Config::get('tables.rang_sup');
|
47 |
$table = Config::get('tables.rang_sup');
|
47 |
$requete_truncate = 'TRUNCATE TABLE '.$table;
|
48 |
$requete_truncate = 'TRUNCATE TABLE '.$table;
|
48 |
$this->efloreCommun->getBdd()->requeter($requete_truncate);
|
49 |
$this->Bdd->requeter($requete_truncate);
|
49 |
foreach ($this->valeurs_insertion as $nn => $valeurs){
|
50 |
foreach ($this->valeurs_insertion as $nn => $valeurs){
|
50 |
$requete = "INSERT INTO $table VALUES($nn, 'bdtfx', '{$valeurs['ve_lumiere']['min']}', ".
|
51 |
$requete = "INSERT INTO $table VALUES('',$nn, 'bdtfx', '{$valeurs['ve_lumiere']['min']}', ".
|
51 |
"'{$valeurs['ve_lumiere']['max']}','{$valeurs['ve_temperature']['min']}',".
|
52 |
"'{$valeurs['ve_lumiere']['max']}','{$valeurs['ve_temperature']['min']}',".
|
52 |
"'{$valeurs['ve_temperature']['max']}','{$valeurs['ve_continentalite']['min']}',".
|
53 |
"'{$valeurs['ve_temperature']['max']}','{$valeurs['ve_continentalite']['min']}',".
|
53 |
"'{$valeurs['ve_continentalite']['max']}','{$valeurs['ve_humidite_atmos']['min']}',".
|
54 |
"'{$valeurs['ve_continentalite']['max']}','{$valeurs['ve_humidite_atmos']['min']}',".
|
54 |
"'{$valeurs['ve_humidite_atmos']['max']}','{$valeurs['ve_humidite_edaph']['min']}',".
|
55 |
"'{$valeurs['ve_humidite_atmos']['max']}','{$valeurs['ve_humidite_edaph']['min']}',".
|
55 |
"'{$valeurs['ve_humidite_edaph']['max']}','{$valeurs['ve_reaction_sol']['min']}',".
|
56 |
"'{$valeurs['ve_humidite_edaph']['max']}','{$valeurs['ve_reaction_sol']['min']}',".
|
56 |
"'{$valeurs['ve_reaction_sol']['max']}','{$valeurs['ve_nutriments_sol']['min']}',".
|
57 |
"'{$valeurs['ve_reaction_sol']['max']}','{$valeurs['ve_nutriments_sol']['min']}',".
|
57 |
"'{$valeurs['ve_nutriments_sol']['max']}','{$valeurs['ve_salinite']['min']}',".
|
58 |
"'{$valeurs['ve_nutriments_sol']['max']}','{$valeurs['ve_salinite']['min']}',".
|
58 |
"'{$valeurs['ve_salinite']['max']}','{$valeurs['ve_texture_sol']['min']}',".
|
59 |
"'{$valeurs['ve_salinite']['max']}','{$valeurs['ve_texture_sol']['min']}',".
|
59 |
"'{$valeurs['ve_texture_sol']['max']}','{$valeurs['ve_mat_org_sol']['min']}',".
|
60 |
"'{$valeurs['ve_texture_sol']['max']}','{$valeurs['ve_mat_org_sol']['min']}',".
|
60 |
"'{$valeurs['ve_mat_org_sol']['max']}');";
|
61 |
"'{$valeurs['ve_mat_org_sol']['max']}');";
|
61 |
$this->efloreCommun->getBdd()->requeter($requete);
|
62 |
$this->Bdd->requeter($requete);
|
62 |
$this->message->afficherAvancement('Insertion des valeurs pour les rangs supérieurs en cours');
|
63 |
$this->message->afficherAvancement('Insertion des valeurs pour les rangs supérieurs en cours');
|
Line 158... |
Line 159... |
158 |
private function consulterInfosTaxons() {
|
159 |
private function consulterInfosTaxons() {
|
159 |
$table = Config::get('tables.taxons');
|
160 |
$table = Config::get('tables.taxons');
|
160 |
$requete = 'SELECT A.num_nom AS nn, B.num_tax_sup AS nn_sup, A.rang '.
|
161 |
$requete = 'SELECT A.num_nom AS nn, B.num_tax_sup AS nn_sup, A.rang '.
|
161 |
"FROM $table A JOIN $table B ON (A.num_nom_retenu = B.num_nom) ".
|
162 |
"FROM $table A JOIN $table B ON (A.num_nom_retenu = B.num_nom) ".
|
162 |
'WHERE B.num_nom = B.num_nom_retenu ';
|
163 |
'WHERE B.num_nom = B.num_nom_retenu ';
|
163 |
$resultat = $this->efloreCommun->getBdd()->recupererTous($requete);
|
164 |
$resultat = $this->Bdd->recupererTous($requete);
|
164 |
foreach ($resultat as $res) {
|
165 |
foreach ($resultat as $res) {
|
165 |
$this->infos_taxon[$res['nn']] = array('nn_sup' => $res['nn_sup'], 'rang' => $res['rang'] );
|
166 |
$this->infos_taxon[$res['nn']] = array('nn_sup' => $res['nn_sup'], 'rang' => $res['rang'] );
|
166 |
}
|
167 |
}
|
167 |
}
|
168 |
}
|
Line 174... |
Line 175... |
174 |
"FROM $table WHERE BDNT = 'BDTFX' ".
|
175 |
"FROM $table WHERE BDNT = 'BDTFX' ".
|
175 |
" AND num_nomen != 0 ".
|
176 |
" AND num_nomen != 0 ".
|
176 |
" AND (ve_lumiere != '' OR ve_mat_org_sol != '' OR ve_temperature != '' ".
|
177 |
" AND (ve_lumiere != '' OR ve_mat_org_sol != '' OR ve_temperature != '' ".
|
177 |
" OR ve_continentalite != '' OR ve_humidite_atmos != '' OR ve_humidite_edaph != '' ".
|
178 |
" OR ve_continentalite != '' OR ve_humidite_atmos != '' OR ve_humidite_edaph != '' ".
|
178 |
" OR ve_nutriments_sol != '' OR ve_salinite != '' OR ve_texture_sol != '' OR ve_reaction_sol != '' )";
|
179 |
" OR ve_nutriments_sol != '' OR ve_salinite != '' OR ve_texture_sol != '' OR ve_reaction_sol != '' )";
|
179 |
$resultat = $this->efloreCommun->getBdd()->recupererTous($requete);
|
180 |
$resultat = $this->Bdd->recupererTous($requete);
|
180 |
foreach ($resultat as $res) {
|
181 |
foreach ($resultat as $res) {
|
181 |
$this->donnees_initiales[$res['num_nomen']] = array(
|
182 |
$this->donnees_initiales[$res['num_nomen']] = array(
|
182 |
've_lumiere' => array('min' => $res['ve_lumiere'], 'max' => $res['ve_lumiere']),
|
183 |
've_lumiere' => array('min' => $res['ve_lumiere'], 'max' => $res['ve_lumiere']),
|
183 |
've_temperature' => array('min' => $res['ve_temperature'], 'max' => $res['ve_temperature']),
|
184 |
've_temperature' => array('min' => $res['ve_temperature'], 'max' => $res['ve_temperature']),
|
184 |
've_continentalite' => array('min' => $res['ve_continentalite'], 'max' => $res['ve_continentalite']),
|
185 |
've_continentalite' => array('min' => $res['ve_continentalite'], 'max' => $res['ve_continentalite']),
|