37,11 → 37,9 |
} |
|
public function consulter($ressources, $parametres) { |
|
$retour = null; |
if(preg_match("/^(nt|nn):([0-9]+)$/", $ressources[0], $matches)) { |
$champ_nt_ou_nn = ($matches[1] == "nn") ? "num_nom" : "num_tax"; |
|
if(count($ressources) == 1) { |
// toutes les infos |
$infos_espece = $this->getInfosEspece($champ_nt_ou_nn, $matches[2]); |
67,6 → 65,9 |
case "presence": |
$retour = $this->getInfosPresence($champ_nt_ou_nn, $matches[2]); |
break; |
case "presence-departement": |
$retour = $this->getInfosPresenceDepartement($champ_nt_ou_nn, $matches[2], $ressources[2]); |
break; |
default: |
$retour = "Actions possibles: noms-vernaculaires, statuts-protection, presence"; |
} |
102,6 → 103,23 |
$somme = implode('+', $colonnes); |
return $somme; |
} |
|
protected function getInfosPresenceDepartement($champ_nt_ou_nn, $nt_ou_nn, $departement) { |
|
// Afin de s'assurer d'une valeur numérique |
$departement = intval($departement); |
// Afin de gérer les noms de colonnes qui commencent par 0 sans imposer de format |
// de nombre à l'entrée du web service |
$departement = $departement < 10 ? "0".$departement : $departement; |
|
$req = "SELECT count(*) > 0 as present". |
" FROM ".$this->table. |
" WHERE ".$champ_nt_ou_nn." = ".$this->getBdd()->proteger($nt_ou_nn).' AND '. |
"`".$departement."` = 1"; |
//echo $req;exit; |
$resultat = $this->getBdd()->recuperer($req); |
return $resultat; |
} |
|
protected function getInfosPresence($champ_nt_ou_nn, $nt_ou_nn) { |
$req = "SELECT " . $this->construireSommeColonnes() . " as nb_presence_zones". |