1996 |
aurelien |
1 |
<?php
|
|
|
2 |
class Dao extends Bdd {
|
|
|
3 |
|
1998 |
aurelien |
4 |
public function obtenirNbObservationsSauvages() {
|
|
|
5 |
$requete = 'SELECT COUNT(*) as nb FROM cel_obs '.
|
|
|
6 |
'WHERE mots_cles_texte LIKE "%sauvages%" '.
|
|
|
7 |
'AND mots_cles_texte LIKE "%Projets coopératifs%" ';
|
|
|
8 |
|
|
|
9 |
$resultat = $this->recuperer($requete);
|
|
|
10 |
return $resultat['nb'];
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
public function obtenirObservationsSauvages($debut, $limite) {
|
1996 |
aurelien |
14 |
$requete = 'SELECT * FROM cel_obs '.
|
|
|
15 |
'WHERE mots_cles_texte LIKE "%sauvages%" '.
|
1998 |
aurelien |
16 |
'AND mots_cles_texte LIKE "%Projets coopératifs%" LIMIT '.$debut.', '.$limite;
|
1996 |
aurelien |
17 |
|
|
|
18 |
$resultat = $this->recupererTous($requete);
|
|
|
19 |
return $resultat;
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
public function ajouterChampsEtendusParLots($obs_a_champs_etendus) {
|
|
|
23 |
$lignes = array();
|
|
|
24 |
|
|
|
25 |
foreach ($obs_a_champs_etendus as $champs_etendus_obs) {
|
|
|
26 |
foreach ($champs_etendus_obs as $champ_etendu) {
|
|
|
27 |
$id = $this->proteger($champ_etendu['id_observation']);
|
|
|
28 |
$cle = $this->proteger($champ_etendu['cle']);
|
|
|
29 |
$label = $this->proteger($champ_etendu['label']);
|
|
|
30 |
$valeur = $this->proteger($champ_etendu['valeur']);
|
|
|
31 |
$lignes[] = "($id, $cle, $label, $valeur)";
|
|
|
32 |
}
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
$requete = "INSERT INTO cel_obs_etendues (id_observation, cle, label, valeur) ".
|
|
|
36 |
"VALUES ".implode(',', $lignes)." ON DUPLICATE KEY UPDATE valeur = VALUES(valeur) -- ".__FILE__.' '.__LINE__;
|
|
|
37 |
|
|
|
38 |
// la partie on duplicate key est spécifique mysql mais il sera facile de s'en passer le jour
|
|
|
39 |
// où l'on change de sgbd
|
|
|
40 |
$ajout = $this->requeter($requete);
|
|
|
41 |
return ($ajout !== false);
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
?>
|