|
本帖最后由 mrcml945 于 2009-4-24 11:40 编辑
function getForumPerTopic($fid)
{
$this->db->select('max(messages.date) as maxdate,topics.*,users.*');
$this->db->from('messages');
$this->db->join('topics','messages.topic_id=topics.id');
$this->db->join('users','topics.user_id=users.id');
$this->db->where('topics.forum_id',$fid);
$this->db->group_by('messages.topic_id');
$this->db->order_by('maxdate','desc');
$query=$this->db->get();
if($query->num_rows() >0)
{
return $query;
}
else
{
return false;
}
} |
|