208 |
jpm |
1 |
<?php
|
|
|
2 |
class NomDAO {
|
|
|
3 |
private $bdd = null;
|
|
|
4 |
private $projet = null;
|
|
|
5 |
private $versions = null;
|
|
|
6 |
|
|
|
7 |
public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd, Projet $projet, Versions $versions) {
|
|
|
8 |
$this->ressources = $ressources;
|
|
|
9 |
$this->parametres = $parametres;
|
|
|
10 |
$this->bdd = $bdd;
|
|
|
11 |
$this->projet = $projet;
|
|
|
12 |
$this->versions = $versions;
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
private function getTable() {
|
|
|
16 |
$versions = $this->versions->getVersions();
|
|
|
17 |
$derniereVersion = end($versions);
|
|
|
18 |
$projetNom = $this->projet->getNom();
|
|
|
19 |
return $projetNom.'_v'.$derniereVersion;
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
public function rechercherInfosNom() {
|
|
|
23 |
$table = $this->getTable();
|
|
|
24 |
$detailsId = $this->ressources->getDetailsId();
|
|
|
25 |
$detailsId = $this->bdd->proteger($detailsId);
|
|
|
26 |
$requete =
|
|
|
27 |
'SELECT ns.*, '.
|
|
|
28 |
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
|
|
|
29 |
"FROM $table AS ns ".
|
|
|
30 |
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
|
|
|
31 |
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
|
|
|
32 |
"WHERE ns.num_nom = $detailsId ";
|
|
|
33 |
$resultats = $this->bdd->recuperer($requete);
|
|
|
34 |
$nom = new NomDO($resultats);
|
|
|
35 |
return $nom;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public function rechercherStricte() {
|
|
|
39 |
$table = $this->getTable();
|
|
|
40 |
$conditions = array();
|
|
|
41 |
if ($masque = $this->parametres->getMasquePourBdd()) {
|
|
|
42 |
$conditions[] = "ns.nom_sci = $masque";
|
|
|
43 |
}
|
|
|
44 |
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
|
|
|
45 |
$conditions[] = "ns.nom_supra_generique = $masqueSg";
|
|
|
46 |
}
|
|
|
47 |
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
|
|
|
48 |
$conditions[] = "ns.genre = $masqueGen";
|
|
|
49 |
}
|
|
|
50 |
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
|
|
|
51 |
$conditions[] = "ns.epithete_sp = $masqueSp";
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
|
|
|
55 |
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
|
|
|
56 |
"FROM $table AS ns ".
|
|
|
57 |
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
|
|
|
58 |
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
|
|
|
59 |
(count($conditions) > 0 ? 'WHERE ' : '').
|
|
|
60 |
implode(' AND ', $conditions).
|
|
|
61 |
'ORDER BY ns.nom_sci ASC '.
|
|
|
62 |
'LIMIT 0,100';
|
|
|
63 |
$resultats = $this->bdd->recupererTous($requete);
|
|
|
64 |
|
|
|
65 |
return $resultats;
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
public function rechercherEtendue() {
|
|
|
69 |
$table = $this->getTable();
|
|
|
70 |
$conditions = array();
|
|
|
71 |
if ($masque = $this->parametres->getMasquePourBdd()) {
|
|
|
72 |
$conditions[] = "ns.nom_sci LIKE $masque";
|
|
|
73 |
}
|
|
|
74 |
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
|
|
|
75 |
$conditions[] = "ns.nom_supra_generique LIKE $masqueSg";
|
|
|
76 |
}
|
|
|
77 |
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
|
|
|
78 |
$conditions[] = "ns.genre LIKE $masqueGen";
|
|
|
79 |
}
|
|
|
80 |
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
|
|
|
81 |
$conditions[] = "ns.epithete_sp LIKE $masqueSp";
|
|
|
82 |
}
|
|
|
83 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
|
|
|
84 |
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
|
|
|
85 |
"FROM $table AS ns ".
|
|
|
86 |
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
|
|
|
87 |
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
|
|
|
88 |
(count($conditions) > 0 ? 'WHERE ' : '').
|
|
|
89 |
implode(' AND ', $conditions).
|
|
|
90 |
'ORDER BY ns.nom_sci ASC '.
|
|
|
91 |
'LIMIT 0,100';
|
|
|
92 |
|
|
|
93 |
$resultats = $this->bdd->recupererTous($requete);
|
|
|
94 |
return $resultats;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
public function rechercherFloue() {
|
|
|
98 |
$table = $this->getTable();
|
|
|
99 |
$masque = $this->parametres->getMasquePourBdd();
|
|
|
100 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
|
|
|
101 |
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
|
|
|
102 |
"FROM $table AS ns ".
|
|
|
103 |
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
|
|
|
104 |
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
|
|
|
105 |
($masque ? 'WHERE '.
|
|
|
106 |
" (SOUNDEX(ns.nom_sci) = SOUNDEX($masque)) ".
|
|
|
107 |
" OR (SOUNDEX(REVERSE(ns.nom_sci)) = SOUNDEX(REVERSE($masque))) " : '').
|
|
|
108 |
'ORDER BY ns.nom_sci ASC '.
|
|
|
109 |
'LIMIT 0,100';
|
|
|
110 |
$resultats = $this->bdd->recupererTous($requete);
|
|
|
111 |
return $resultats;
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
public function recupererNombreNomsTotal() {
|
|
|
115 |
$requete = 'SELECT FOUND_ROWS() AS nbre';
|
|
|
116 |
$nombre = $this->bdd->recuperer($requete);
|
|
|
117 |
return (int) $nombre['nbre'];
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
?>
|