Re : loadobjectlist + php
et à tout hasard en mettant les majuscules à loadobjectlist pour être bien conforme au code ?
et à tout hasard en mettant les majuscules à loadobjectlist pour être bien conforme au code ?
function getlistage($limit,$type) {
$db = & JFactory :: getDBO();
$result = array();
$filter = $this->createwheresaad();
$where = ' where e.published = 1 ';
$where .= ' and e.id_soustype = st.id';
$where .= ' and st.id_type = '.$type.'';
$query1 = "SELECT COUNT(e.id) FROM #__f_evenement e, #__f_soustype st ";
if($filter)
$query1 .= $filter ;
$query1 .= ' and e.id_soustype = st.id';
$query1 .= ' and st.id_type = '.$type.'';
$db->setQuery($query1);
$total = $db->loadResult();
$query1 = "SELECT COUNT(e.id) FROM #__f_evenement e, #__f_soustype st ";
if($filter)
$query1 .= $filter;
$db->setQuery($query1);
$totalcategorie = $db->loadResult();
//$arrayquand = "('Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche')";
$query2 = "SELECT distinct JOUR_DEBUT,JOUR_FIN FROM #__f_evenement ".$filter." order by JOUR_DEBUT ";
$db->setQuery($query2);
$date_afficher = $db->loadObjectList();
$query2 = "SELECT count(*) FROM (SELECT distinct JOUR_DEBUT, JOUR_FIN FROM #__f_evenement ".$filter.") as saad ";
$db->setQuery($query2);
$totaldate = $db->loadResult();
$query3 = "SELECT count(*) FROM #__f_evenement ".$filter." and HFIN < '12:00' ";
$db->setQuery($query3);
$horaire_afficher['matin'] = $db->loadresult();
$query3 = "SELECT count(*) FROM #__f_evenement ".$filter." and (HDEB >= '12:00' and HFIN <= '14:00') ";
$db->setQuery($query3);
$horaire_afficher['midi'] = $db->loadresult();
$query3 = "SELECT count(*) FROM #__f_evenement ".$filter." and (HDEB > '14:00' and HFIN <= '18:00') ";
$db->setQuery($query3);
$horaire_afficher['apresmidi'] = $db->loadresult();
$query3 = "SELECT count(*) FROM #__f_evenement ".$filter." and HDEB > '18:00' ";
$db->setQuery($query3);
$horaire_afficher['soir'] = $db->loadresult();
$query3 = "SELECT count(*) FROM #__f_evenement ".$filter." and (HDEB <= '10:00' and HFIN >= '17:00') ";
$db->setQuery($query3);
$horaire_afficher['journeeentiere'] = $db->loadresult();
$query = "SELECT *, e.id as eid FROM #__f_evenement e, #__f_soustype st ";
if($filter)
$query .= $filter;
$query .= ' order by st.id ';
$db->setQuery($query,$this->limitstart, $limit);
$this->_application = $db->loadObjectList();
$saad=$query;
$query = 'SELECT lieu , count(*) as counter FROM #__f_evenement '.$filter.' group by lieu ' ;
$db->setQuery($query);
$lieu = $db->loadObjectlist();
$query = 'select id, Nom_Lieu from #__f_lieuHY where id in (select distinct(lieu) FROM #__f_evenement ) order by Nom_Lieu' ;
$db->setQuery($query);
$lieunom = $db->loadObjectlist();
$result[0] = $this->_application;
$result[1] = $total;
$result[2] = $date_afficher;
$result[3] = $horaire_afficher;
$result[4] = $lieu;
$result[5] = $lieunom;
$result[6] = $totalcategorie;
$result[7] = $saad;
$result[8] = $totaldate;
return $result;
}
function createwheresaad() {
$session =& JFactory::getSession();
$where = ' where e.published = 1 ';
if($type) {
//$typevalue = implode('","', $type);
$where .= ' and e.id_soustype = st.id';
$where .= ' and st.id_type = '.$type.'';
}
$retour = JRequest::getvar('retour');
if(!$retour){
$ou = JRequest::getvar('ou',false);
$quand = JRequest::getvar('quand',false);
$horaire = JRequest::getvar('horaire',false);
$qui = JRequest::getvar('qui',false);
$type = JRequest::getvar('type',false);
//$retour = JRequest::getvar('retour',false);
$limitstar = JRequest::getvar('limitstart',$session->get('qui',false));
}else{
$ou = $session->get('ou');
$quand = $session->get('quand');
$horaire = $session->get('horaire');
$qui = $session->get('qui');
$type = $session->get('type');
//$retour = $session->get('retour');
$limitstar = $session->get('limitstart');
}
$session->set('ou',$ou);
$session->set('quand',$quand);
$session->set('horaire',$horaire);
$session->set('qui',$qui);
$session->set('type',$type);
//$session->set('retour',$retour);
$session->set('limitstart',$limitstar);
$this->limitstart = $limitstar;
if($ou) {
$ouvalue = implode(',', $ou);
$where .= ' and lieu in ('.$ouvalue.') ';
}
if($quand) {
$quandvalue = explode(',', $quand);
$where .= ' and JOUR_DEBUT ="'.$quandvalue[0].'" and JOUR_FIN ="'.$quandvalue[1].'"';
}
if($horaire) {
/*$horairevalue = implode('","', $horaire);
$where .= ' and horaire_afficher in ("'.$horairevalue.'") ';*/
if(in_array('matin',$horaire)) {
$horairearray[] = ' HFIN < "12:00" ';
}
if(in_array('midi',$horaire)) {
$horairearray[] = ' (HDEB >= "12:00" and HFIN <= "14:00") ';
}
if(in_array('apresmidi',$horaire)) {
$horairearray[] = ' (HDEB > "14:00" and HFIN <= "18:00") ';
}
if(in_array('soir',$horaire)) {
$horairearray[] = ' HDEB > "18:00" ';
}
if(in_array('journeeentiere',$horaire)) {
$horairearray[] = ' (HDEB <= "10:00" and HFIN >= "17:00") ';
}
$where .= 'and ( '.implode(' or ', $horairearray ).' )';
}
if($qui) {
switch($qui){
case 'Adultes':
$where .= ' and age_min <= 24 and age_max >= 18';
break;
case 'Seniors':
$where .= ' and age_min >= 25 ';
break;
default :
$where .= ' and age_min <= '.$qui.' and age_max >= '.$qui.'';
break;
}
}
if($type) {
//$typevalue = implode('","', $type);
$where .= ' and e.id_soustype = st.id';
$where .= ' and st.id_type = '.$type.'';
}
return $where ;
}
$query2 = "SELECT distinct JOUR_DEBUT,JOUR_FIN FROM #__f_evenement ".$filter." order by JOUR_DEBUT ";
$db->setQuery($query2);
$date_afficher = $db->loadObjectList();
$query = 'SELECT lieu , count(*) as counter FROM #__f_evenement '.$filter.' group by lieu ' ;
$db->setQuery($query);
$lieu = $db->loadObjectlist();
$where .= ' and [B][COLOR="red"]e[/COLOR][/B].id_soustype = st.id'; $where .= ' and[B][COLOR="red"] st[/COLOR][/B].id_type = '.$type.'';
$query2 = "SELECT count(*) FROM (SELECT distinct JOUR_DEBUT, JOUR_FIN FROM #__f_evenement, #__f_soustype st ".$filter.") as saad ";
$db->setQuery($query2);
$totaldate = $db->loadResult();
$query = 'SELECT lieu , count(*) as counter FROM #__f_evenement, #__f_soustype st '.$filter.' group by lieu ' ;
$db->setQuery($query);
$lieu = $db->loadObjectlist();
$query1 = "SELECT COUNT(e.id) FROM #__f_evenement e, #__f_soustype st ";
if($filter)
$query1 .= $filter;
if($type) {
//$typevalue = implode('","', $type);
$where .= ' and e.id_soustype = st.id';
$where .= ' and st.id_type = '.$type.'';
}
echo $query
print_r ($row)
Commentaire