1996 |
aurelien |
1 |
<?php
|
2415 |
jpm |
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Contient les requêtes effecturant la migration pour Sauvages.
|
|
|
5 |
*
|
|
|
6 |
* @category CEL
|
|
|
7 |
* @package Scripts
|
|
|
8 |
* @subpackage Migration : Sauvages
|
|
|
9 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
|
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
11 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
|
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
14 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
|
|
15 |
*/
|
1996 |
aurelien |
16 |
class Dao extends Bdd {
|
2014 |
jpm |
17 |
|
1998 |
aurelien |
18 |
public function obtenirNbObservationsSauvages() {
|
2014 |
jpm |
19 |
$requete = 'SELECT COUNT(*) AS nb '.
|
|
|
20 |
'FROM cel_obs '.
|
|
|
21 |
'WHERE mots_cles_texte LIKE "%sauvages%" '.
|
|
|
22 |
' AND mots_cles_texte LIKE "%Projets coopératifs%" '.
|
2017 |
jpm |
23 |
' AND mots_cles_texte NOT LIKE "%florileges%" '.
|
2014 |
jpm |
24 |
' -- '.__FILE__.' '.__LINE__;
|
|
|
25 |
|
1998 |
aurelien |
26 |
$resultat = $this->recuperer($requete);
|
|
|
27 |
return $resultat['nb'];
|
|
|
28 |
}
|
2014 |
jpm |
29 |
|
1998 |
aurelien |
30 |
public function obtenirObservationsSauvages($debut, $limite) {
|
2014 |
jpm |
31 |
$requete = 'SELECT * '.
|
|
|
32 |
'FROM cel_obs '.
|
|
|
33 |
'WHERE mots_cles_texte LIKE "%sauvages%" '.
|
|
|
34 |
' AND mots_cles_texte LIKE "%Projets coopératifs%" '.
|
2017 |
jpm |
35 |
' AND mots_cles_texte NOT LIKE "%florileges%" '.
|
2014 |
jpm |
36 |
"LIMIT $debut, $limite ".
|
|
|
37 |
' -- '.__FILE__.' '.__LINE__;
|
1996 |
aurelien |
38 |
|
|
|
39 |
$resultat = $this->recupererTous($requete);
|
|
|
40 |
return $resultat;
|
|
|
41 |
}
|
2014 |
jpm |
42 |
|
1996 |
aurelien |
43 |
public function ajouterChampsEtendusParLots($obs_a_champs_etendus) {
|
|
|
44 |
$lignes = array();
|
2014 |
jpm |
45 |
|
1996 |
aurelien |
46 |
foreach ($obs_a_champs_etendus as $champs_etendus_obs) {
|
|
|
47 |
foreach ($champs_etendus_obs as $champ_etendu) {
|
|
|
48 |
$id = $this->proteger($champ_etendu['id_observation']);
|
|
|
49 |
$cle = $this->proteger($champ_etendu['cle']);
|
|
|
50 |
$label = $this->proteger($champ_etendu['label']);
|
2014 |
jpm |
51 |
$valeur = $this->proteger($champ_etendu['valeur']);
|
1996 |
aurelien |
52 |
$lignes[] = "($id, $cle, $label, $valeur)";
|
|
|
53 |
}
|
|
|
54 |
}
|
2014 |
jpm |
55 |
|
1996 |
aurelien |
56 |
$requete = "INSERT INTO cel_obs_etendues (id_observation, cle, label, valeur) ".
|
2014 |
jpm |
57 |
'VALUES '.implode(',', $lignes).' '.
|
|
|
58 |
'ON DUPLICATE KEY UPDATE valeur = VALUES(valeur) '.
|
|
|
59 |
'-- '.__FILE__.' '.__LINE__;
|
|
|
60 |
|
1996 |
aurelien |
61 |
// la partie on duplicate key est spécifique mysql mais il sera facile de s'en passer le jour
|
|
|
62 |
// où l'on change de sgbd
|
|
|
63 |
$ajout = $this->requeter($requete);
|
|
|
64 |
return ($ajout !== false);
|
|
|
65 |
}
|
2415 |
jpm |
66 |
}
|