Line 24... |
Line 24... |
24 |
public function getElement($param = array()) {
|
24 |
public function getElement($param = array()) {
|
25 |
// Initialisation des variables
|
25 |
// Initialisation des variables
|
26 |
$info = array();
|
26 |
$info = array();
|
Line 27... |
Line 27... |
27 |
|
27 |
|
28 |
// Pré traitement des paramêtres
|
28 |
// Pré traitement des paramêtres
|
Line 29... |
Line 29... |
29 |
$p = $this->traiterParametresUrl(array('id_collection', 'id_role'), $param);
|
29 |
$p = $this->traiterParametresUrl(array('id_collection', 'id_role', 'id_personne'), $param);
|
30 |
|
30 |
|
- |
|
31 |
// Construction de la requête
|
- |
|
32 |
$requete = (($this->distinct) ? 'SELECT DISTINCT ' : 'SELECT ').
|
31 |
// Construction de la requête
|
33 |
' ccap.*, '.
|
32 |
$requete = (($this->distinct) ? 'SELECT DISTINCT ' : 'SELECT ').
|
34 |
(isset($p['id_personne']) ? ' cc_nom, ' : '').
|
33 |
' ccap.*, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom, cp_naissance_date, cp_naissance_lieu, cp_ce_deces, cp_deces_date, cp_deces_lieu '.
|
35 |
' cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom, cp_naissance_date, cp_naissance_lieu, cp_ce_deces, cp_deces_date, cp_deces_lieu '.
|
34 |
'FROM coel_collection_a_personne AS ccap '.
|
36 |
'FROM coel_collection_a_personne AS ccap '.
|
- |
|
37 |
' LEFT JOIN coel_meta_historique_ligne ON (ccap_ce_meta = cmhl_id_historique_ligne) '.
|
35 |
' LEFT JOIN coel_meta_historique_ligne ON (ccap_ce_meta = cmhl_id_historique_ligne) '.
|
38 |
' LEFT JOIN coel_personne ON (ccap_id_personne = cp_id_personne) '.
|
36 |
' LEFT JOIN coel_personne ON (ccap_id_personne = cp_id_personne) '.
|
39 |
(isset($p['id_personne']) ? ' LEFT JOIN coel_collection ON (ccap_id_collection = cc_id_collection) ' : '').
|
37 |
((count($p) != 0) ? 'WHERE ' : '').
|
40 |
((count($p) != 0) ? 'WHERE ' : '').
|
- |
|
41 |
(isset($p['id_collection']) ? "AND ccap_id_collection = {$p['id_collection']} " : '').
|
38 |
(isset($p['id_collection']) ? "AND ccap_id_collection = {$p['id_collection']} " : '').
|
42 |
(isset($p['id_role']) ? "AND ccap_id_role = {$p['id_role']} " : '').
|
39 |
(isset($p['id_role']) ? "AND ccap_id_role = {$p['id_role']} " : '').
|
43 |
(isset($p['id_personne']) ? "AND ccap_id_personne = {$p['id_personne']} " : '').
|
40 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'ccap_ce_meta DESC').' ';
|
44 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'ccap_ce_meta DESC').' ';
|
41 |
$requete = str_replace('WHERE AND', 'WHERE', $requete);
|
45 |
$requete = str_replace('WHERE AND', 'WHERE', $requete);
|
Line 42... |
Line 46... |
42 |
$requeteCount = $requete;
|
46 |
$requeteCount = $requete;
|
43 |
$requete .= "LIMIT $this->start, $this->limit ";
|
47 |
$requete .= "LIMIT $this->start, $this->limit ";
|
- |
|
48 |
|
44 |
|
49 |
// Récupération des résultats
|
45 |
// Récupération des résultats
|
- |
|
46 |
try {
|
50 |
try {
|
47 |
$donnees = $this->bdd->query($requete)->fetchAll();
|
51 |
$nbElements = 0;
|
- |
|
52 |
$donnees = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
|
- |
|
53 |
if ($donnees === false) {
|
48 |
|
54 |
$this->messages[] = "La requête a retourné aucun résultat.";
|
Line 49... |
Line -... |
49 |
if ($donnees === false) {
|
- |
|
50 |
$this->messages[] = "La requête a retourné aucun résultat.";
|
- |
|
51 |
}
|
55 |
} else {
|
52 |
|
56 |
$nbElements = $this->bdd->query($requeteCount)->rowCount();
|
Line 53... |
Line 57... |
53 |
$nbElements = $this->bdd->query($requeteCount)->rowCount();
|
57 |
}
|
54 |
|
58 |
|