我需要按 rand 订购,但我不希望它在每次刷新时都改变,我只需要一个随机数,这有意义吗?
这是我的代码:
function findSimilarByTag($gid,$limit=5) {
$gid=$this->quotesmart($gid);
$limit=$this->quotesmart($limit); //yes, this is senseless
$db =& JFactory::getDBO();
$query ="SELECT count( a.cid ) , a.gid, b.* \r\n";
$query.="FROM `#__yfl_game2cat` a \r\n";
$query.="JOIN #__yfl_game b ON a.gid = b.id
WHERE a.cid
IN (
SELECT cid
FROM #__yfl_game2cat
WHERE gid = '$gid'
)
AND a.gid != '$gid'
GROUP BY a.gid
ORDER BY rand()
LIMIT ".$limit;
$db->setQuery($query);
$games=$db->loadObjectList();
if($db->getErrorMsg()) $games=$db->getErrorMsg();
return $games;