如果关联时逻辑很复杂,或者不知道有其它办法的情况下。
不得已可以使用下面的方法。
//正在拍卖
$sql = mysql_query("SELECT s.id,s.goodsname,s.starttime,s.keeptime,s.auctionprice,s.uid,s.goodspicshow,t.username,count(a.gid) pcount FROM shop_auction_list s
Left JOIN t_users t ON s.uid=t.userid
left join auction_nowprice_history a on s.id=a.gid
where s.stock>0 and s.auctionprice>s.price group by s.id order by s.id desc limit 0,8");
while($rs=mysql_fetch_array($sql)){
$isf=$db->getone("select count(*) from shop_follow where gid='".$rs['id']."' and fuid='".$uid."' and isauc=1");
$rs["isf"]=$isf;
$auctionsql[]=$rs;
}
$smarty->assign("nowtime",time());
$smarty->assign("auctionsql", $auctionsql);