Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 123 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
class TAXON_RECHERCHE extends macroElement {
    function getSQL()
    {
        $contexte = array();
        if (array_key_exists('nvp', $this->contexteRef) and 
            array_key_exists('rg', $this->contexteRef)  and 
            array_key_exists('od', $this->contexteRef)) {
            
            $contexte['nvp'] = $this->contexteRef['nvp'];
            $contexte['rg'] = $this->contexteRef['rg'];
            $contexte['od'] = $this->contexteRef['od'];
            if (!empty($contexte['nvp']) && !empty($contexte['rg']) && !empty($contexte['od'])) {
                $requete = 
                'SELECT DISTINCT 
                nom.en_id_nom,
                intitule.eni_intitule_nom,
                selection.esn_id_taxon,
                selection.esn_id_version_projet_taxon
               
                FROM 
                eflore_nom AS nom,
                eflore_nom_intitule AS intitule,
                eflore_selection_nom AS selection
                
                WHERE 
                nom.en_id_nom = intitule.eni_id_nom
                AND intitule.eni_id_categorie_format = 3
                AND intitule.eni_id_valeur_format = 4
                AND selection.esn_id_nom = nom.en_id_nom 
                AND selection.esn_ce_statut = 3 
                AND selection.esn_id_version_projet_taxon = '.$contexte['nvp'].' ';
                switch ($contexte['od']) {
                    case 'sup' :
                        $requete .= 'AND nom.en_ce_rang < '.$contexte['rg'].' ';
                        break;
                    case 'ega' :
                        $requete .= 'AND nom.en_ce_rang = '.$contexte['rg'].' ';
                        break;
                    case 'inf' :
                        $requete .= 'AND nom.en_ce_rang > '.$contexte['rg'].' ';
                        break;
                }
                $requete .= 'ORDER BY intitule.eni_intitule_nom ASC';
                return $requete;
            }
        }
        return null;
    }
}
?>