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