1 |
<?php
|
1 |
<?php
|
2 |
// declare(encoding='UTF-8');
|
2 |
// declare(encoding='UTF-8');
|
3 |
/**
|
3 |
/**
|
4 |
* Modèle d'accès à la base de données des Collections pour la Recherche
|
4 |
* Modèle d'accès à la base de données des Collections pour la Recherche
|
5 |
*
|
5 |
*
|
6 |
* @package Collection
|
6 |
* @package Collection
|
7 |
* @category php5
|
7 |
* @category php5
|
8 |
* @author aurelien <aurelien@tela-botanica.org>
|
8 |
* @author aurelien <aurelien@tela-botanica.org>
|
9 |
* @copyright 2010 Tela-Botanica
|
9 |
* @copyright 2010 Tela-Botanica
|
10 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
10 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
11 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
11 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
12 |
* @version SVN: $Id$
|
12 |
* @version SVN: $Id$
|
13 |
*
|
13 |
*
|
14 |
*/
|
14 |
*/
|
15 |
class RechercheDao extends ColModele {
|
15 |
class RechercheDao extends ColModele {
|
16 |
|
16 |
|
17 |
/**
|
17 |
/**
|
18 |
* Recherche une collection en fonction de paramêtres
|
18 |
* Recherche une collection en fonction de paramêtres
|
19 |
* @return array un tableau contenant des objets d'informations sur les collections
|
19 |
* @return array un tableau contenant des objets d'informations sur les collections
|
20 |
*/
|
20 |
*/
|
21 |
public function chercherStructureNbre($parametres) {
|
21 |
public function chercherStructureNbre($parametres) {
|
22 |
$requete = 'SELECT COUNT(cc_id_collection) AS nbre '.
|
22 |
$requete = 'SELECT COUNT(cc_id_collection) AS nbre '.
|
23 |
'FROM coel_collection LEFT JOIN coel_structure ON (cc_ce_structure = cs_id_structure) '.
|
23 |
'FROM coel_collection LEFT JOIN coel_structure ON (cc_ce_structure = cs_id_structure) '.
|
24 |
'WHERE ('.
|
24 |
'WHERE ('.
|
25 |
" cc_nom LIKE '%{$parametres['mots']}%' ".
|
25 |
" cc_nom LIKE '%{$parametres['mots']}%' ".
|
26 |
" OR cc_truk_nom_alternatif LIKE '%{$parametres['mots']}%' ".
|
26 |
" OR cc_truk_nom_alternatif LIKE '%{$parametres['mots']}%' ".
|
27 |
" OR cc_truk_code LIKE '%{$parametres['mots']}%' ".
|
27 |
" OR cc_truk_code LIKE '%{$parametres['mots']}%' ".
|
28 |
" OR cc_description LIKE '%{$parametres['mots']}%' ".
|
28 |
" OR cc_description LIKE '%{$parametres['mots']}%' ".
|
29 |
" OR cc_description_specialiste LIKE '%{$parametres['mots']}%' ".
|
29 |
" OR cc_description_specialiste LIKE '%{$parametres['mots']}%' ".
|
30 |
" OR cc_historique LIKE '%{$parametres['mots']}%' ".
|
30 |
" OR cc_historique LIKE '%{$parametres['mots']}%' ".
|
31 |
|
31 |
|
32 |
" OR cs_nom LIKE '%{$parametres['mots']}%' ".
|
32 |
" OR cs_nom LIKE '%{$parametres['mots']}%' ".
|
33 |
" OR cs_adresse_01 LIKE '%{$parametres['mots']}%' ".
|
33 |
" OR cs_adresse_01 LIKE '%{$parametres['mots']}%' ".
|
34 |
" OR cs_adresse_02 LIKE '%{$parametres['mots']}%' ".
|
34 |
" OR cs_adresse_02 LIKE '%{$parametres['mots']}%' ".
|
35 |
" OR cs_ville LIKE '%{$parametres['mots']}%' ".
|
35 |
" OR cs_ville LIKE '%{$parametres['mots']}%' ".
|
36 |
" OR cs_truk_identifiant_alternatif LIKE '%{$parametres['mots']}%' ".
|
36 |
" OR cs_truk_identifiant_alternatif LIKE '%{$parametres['mots']}%' ".
|
37 |
') '.
|
37 |
') '.
|
38 |
'ORDER BY cs_ville ASC, cc_nom ASC ';
|
38 |
'ORDER BY cs_ville ASC, cc_nom ASC ';
|
39 |
|
39 |
|
40 |
$donnees = $this->requeteUn($requete);
|
40 |
$donnees = $this->requeteUn($requete);
|
41 |
//Debug::printr($requete);
|
41 |
//Debug::printr($requete);
|
42 |
return $donnees['nbre'];
|
42 |
return $donnees['nbre'];
|
43 |
}
|
43 |
}
|
44 |
|
44 |
|
45 |
/**
|
45 |
/**
|
46 |
* Recherche une collection en fonction de paramêtres
|
46 |
* Recherche une collection en fonction de paramêtres
|
47 |
* @return array un tableau contenant des objets d'informations sur les collections
|
47 |
* @return array un tableau contenant des objets d'informations sur les collections
|
48 |
*/
|
48 |
*/
|
49 |
public function chercher($parametres) {
|
49 |
public function chercher($parametres) {
|
50 |
$requete = 'SELECT cs_id_structure, cs_ville, cs_nom, '.
|
50 |
$requete = 'SELECT cs_id_structure, cs_ville, cs_nom, '.
|
51 |
' cc_nom '.
|
51 |
' cc_id_collection, cc_nom '.
|
52 |
'FROM coel_collection LEFT JOIN coel_structure ON (cc_ce_structure = cs_id_structure) '.
|
52 |
'FROM coel_collection LEFT JOIN coel_structure ON (cc_ce_structure = cs_id_structure) '.
|
53 |
'WHERE ('.
|
53 |
'WHERE ('.
|
54 |
" cc_nom LIKE '%{$parametres['mots']}%' ".
|
54 |
" cc_nom LIKE '%{$parametres['mots']}%' ".
|
55 |
" OR cc_truk_nom_alternatif LIKE '%{$parametres['mots']}%' ".
|
55 |
" OR cc_truk_nom_alternatif LIKE '%{$parametres['mots']}%' ".
|
56 |
" OR cc_truk_code LIKE '%{$parametres['mots']}%' ".
|
56 |
" OR cc_truk_code LIKE '%{$parametres['mots']}%' ".
|
57 |
" OR cc_description LIKE '%{$parametres['mots']}%' ".
|
57 |
" OR cc_description LIKE '%{$parametres['mots']}%' ".
|
58 |
" OR cc_description_specialiste LIKE '%{$parametres['mots']}%' ".
|
58 |
" OR cc_description_specialiste LIKE '%{$parametres['mots']}%' ".
|
59 |
" OR cc_historique LIKE '%{$parametres['mots']}%' ".
|
59 |
" OR cc_historique LIKE '%{$parametres['mots']}%' ".
|
60 |
|
60 |
|
61 |
" OR cs_nom LIKE '%{$parametres['mots']}%' ".
|
61 |
" OR cs_nom LIKE '%{$parametres['mots']}%' ".
|
62 |
" OR cs_adresse_01 LIKE '%{$parametres['mots']}%' ".
|
62 |
" OR cs_adresse_01 LIKE '%{$parametres['mots']}%' ".
|
63 |
" OR cs_adresse_02 LIKE '%{$parametres['mots']}%' ".
|
63 |
" OR cs_adresse_02 LIKE '%{$parametres['mots']}%' ".
|
64 |
" OR cs_ville LIKE '%{$parametres['mots']}%' ".
|
64 |
" OR cs_ville LIKE '%{$parametres['mots']}%' ".
|
65 |
" OR cs_truk_identifiant_alternatif LIKE '%{$parametres['mots']}%' ".
|
65 |
" OR cs_truk_identifiant_alternatif LIKE '%{$parametres['mots']}%' ".
|
66 |
') '.
|
66 |
') '.
|
67 |
'ORDER BY cs_ville ASC, cc_nom ASC '.
|
67 |
'ORDER BY cs_ville ASC, cc_nom ASC '.
|
68 |
($this->avoirLimitation() ? "LIMIT {$this->getLimiteDebut()}, {$this->getLimiteNbre()} " : '');
|
68 |
($this->avoirLimitation() ? "LIMIT {$this->getLimiteDebut()}, {$this->getLimiteNbre()} " : '');
|
69 |
|
69 |
|
70 |
$donnees = $this->requeteTous($requete);
|
70 |
$donnees = $this->requeteTous($requete);
|
71 |
//Debug::printr($requete);
|
71 |
//Debug::printr($requete);
|
72 |
return $donnees;
|
72 |
return $donnees;
|
73 |
}
|
73 |
}
|
74 |
}
|
74 |
}
|
75 |
?>
|
75 |
?>
|