Titre du sujet : Re: Plus de 500 requête sur la page index de xoopstube (c'est beaucoup) par seboseboss sur 16/01/2015 02:45:56
Re
Merci olivee t'a raison c'est bien cette fonction qui est en cause, me reste plus qu'a la modifier car les catégories alternative servent à rien dans mon cas.
EDIT: Problème résolu
y'avais bien une boucle de requêtes concernant les catégories alternative. commenté comme suit:
function xtube_getTotalItems($sel_id = 0, $get_child = 0, $return_sql = 0) {
global $xoopsDB, $mytree, $_check_array;
if ($sel_id > 0) {
$sql = 'SELECT a.lid, a.cid, a.published FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' a LEFT JOIN '
. $xoopsDB->prefix('xoopstube_altcat') . ' b' . ' ON b.lid=a.lid'
. ' WHERE a.published > 0 AND a.published <= ' . time() . ' AND (a.expired = 0 OR a.expired > ' . time()
. ') AND offline = 0 ' . ' AND (b.cid=a.cid OR (a.cid=' . $sel_id . ' OR b.cid=' . $sel_id . '))'
. ' GROUP BY a.lid, a.cid, a.published';
} else {
$sql = 'SELECT lid, cid, published FROM ' . $xoopsDB->prefix('xoopstube_videos')
. ' WHERE offline = 0 AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > '
. time() . ')';
}
if ($return_sql == 1) {
return $sql;
}
$count = 0;
$published_date = 0;
$arr = array();
$result = $xoopsDB->query($sql);
while (list($lid, $cid, $published) = $xoopsDB->fetchRow($result)) {
if (TRUE == xtube_checkgroups()) {
$count++;
$published_date = ($published > $published_date) ? $published : $published_date;
}
}
/*
$child_count = 0;
if ($get_child == 1) {
$arr = $mytree->getAllChildId($sel_id);
$size = count($arr);
for ($i = 0; $i < count($arr); $i++) {
$query2 = 'SELECT a.lid, a.published, a.cid FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' a LEFT JOIN '
. $xoopsDB->prefix('xoopstube_altcat') . ' b' . ' ON b.lid = a.lid'
. ' WHERE a.published > 0 AND a.published <= ' . time() . ' AND (a.expired = 0 OR a.expired > ' . time()
. ') AND offline = 0' . ' AND (b.cid=a.cid OR (a.cid=' . $arr[$i] . ' OR b.cid=' . $arr[$i]
. ')) GROUP BY a.lid, a.published, a.cid';
$result2 = $xoopsDB->query($query2);
while (list($lid, $published) = $xoopsDB->fetchRow($result2)) {
if ($published == 0) {
continue;
}
$published_date = ($published > $published_date) ? $published : $published_date;
$child_count++;
}
}
}*/
$info['count'] = $count /*+ $child_count*/;
$info['published'] = $published_date;
return $info;
}
Résultat: 490 requêtes de moins, il en reste 62, magnifique.
|