10,13 → 10,6 |
$this->versions = $versions; |
} |
|
private function getTable() { |
$versions = $this->versions->getVersions(); |
$derniereVersion = end($versions); |
$projetNom = strtolower($this->ressources->getProjetNom()); |
return $projetNom.'_v'.$derniereVersion; |
} |
|
public function rechercherInfosNom() { |
$table = $this->getTable(); |
$detailsId = $this->ressources->getDetailsId(); |
33,29 → 26,18 |
return $nom; |
} |
|
public function rechercherStricte() { |
public function rechercher() { |
$table = $this->getTable(); |
$conditions = array(); |
if ($masque = $this->parametres->getMasquePourBdd()) { |
$conditions[] = "ns.nom_sci = $masque"; |
} |
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) { |
$conditions[] = "ns.nom_supra_generique = $masqueSg"; |
} |
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) { |
$conditions[] = "ns.genre = $masqueGen"; |
} |
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) { |
$conditions[] = "ns.epithete_sp = $masqueSp"; |
} |
$conditions = $this->getConditions(); |
$where = $this->getWhere($conditions); |
$navigation = $this->getNavigation(); |
|
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '. |
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '. |
"FROM $table AS ns ". |
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ". |
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ". |
$this->getWhere($conditions). |
implode(' AND ', $conditions). |
$where.$conditions. |
'ORDER BY ns.nom_sci ASC '. |
"LIMIT $navigation "; |
|
64,36 → 46,6 |
return $resultats; |
} |
|
public function rechercherEtendue() { |
$table = $this->getTable(); |
$conditions = array(); |
if ($masque = $this->parametres->getMasquePourBdd()) { |
$conditions[] = "ns.nom_sci LIKE $masque"; |
} |
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) { |
$conditions[] = "ns.nom_supra_generique LIKE $masqueSg"; |
} |
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) { |
$conditions[] = "ns.genre LIKE $masqueGen"; |
} |
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) { |
$conditions[] = "ns.epithete_sp LIKE $masqueSp"; |
} |
$navigation = $this->getNavigation(); |
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '. |
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '. |
"FROM $table AS ns ". |
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ". |
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ". |
$this->getWhere($conditions). |
implode(' AND ', $conditions). |
'ORDER BY ns.nom_sci ASC '. |
"LIMIT $navigation "; |
|
$resultats = $this->bdd->recupererTous($requete); |
return $resultats; |
} |
|
public function rechercherFloue() { |
$table = $this->getTable(); |
$masque = $this->parametres->getMasquePourBdd(); |
114,23 → 66,65 |
return $resultats; |
} |
|
private function getNavigation() { |
$debut = (int) $this->parametres->get('navigation.depart'); |
$nbre = $this->parametres->get('navigation.limite'); |
$navigation = "$debut,$nbre"; |
return $navigation; |
private function getTable() { |
$versions = $this->versions->getVersions(); |
$derniereVersion = end($versions); |
$projetNom = strtolower($this->ressources->getProjetNom()); |
return $projetNom.'_v'.$derniereVersion; |
} |
|
private function getWhere($conditions = array()) { |
private function getConditions() { |
$masquesStrictes = array('nn', 'rg'); |
$paramsMasque = array( |
'' => 'nom_sci', |
'nn' => 'num_nom', |
'rg' => 'rang', |
'sg' => 'nom_supra_generique', |
'gen' => 'genre', |
'sp' => 'epithete_sp', |
'ssp' => 'epithete_infra_sp', |
'au' => 'auteur', |
'an' => 'annee'); |
|
$operateurParDefaut = $this->getOperateurCondition(); |
$conditionsSql = array(); |
foreach ($paramsMasque as $typeMasque => $champ) { |
$operateur = in_array($typeMasque, $masquesStrictes) ? '=' : $operateurParDefaut; |
if ($valeurMasque = $this->parametres->getMasquePourBdd($typeMasque)) { |
$conditionsSql[] = "ns.$champ $operateur $valeurMasque"; |
} |
} |
return implode(' AND ', $conditionsSql); |
} |
|
private function getOperateurCondition() { |
$operateur = ''; |
$recherche = $this->parametres->get('recherche'); |
if ($recherche == 'stricte') { |
$operateur = '='; |
} else if ($recherche == 'etendue') { |
$operateur = 'LIKE'; |
} |
return $operateur; |
} |
|
private function getWhere($conditions = '') { |
$where = ''; |
if ($this->ressources->getServiceNom() == 'taxons') { |
$where = 'WHERE ns.num_nom = ns.num_nom_retenu '; |
} else if (count($conditions) > 0) { |
} else if ($conditions != '') { |
$where = 'WHERE '; |
} |
return $where; |
} |
|
private function getNavigation() { |
$debut = (int) $this->parametres->get('navigation.depart'); |
$nbre = $this->parametres->get('navigation.limite'); |
$navigation = "$debut,$nbre"; |
return $navigation; |
} |
|
public function recupererNombreNomsTotal() { |
$requete = 'SELECT FOUND_ROWS() AS nbre'; |
$nombre = $this->bdd->recuperer($requete); |