예제 #1
0
        $comment_array['total'] = $rows_num;
        $offset = $page_num * $per_page;
        //计算偏移量
        $limit = ' LIMIT ' . $offset . ', ' . $per_page;
        $sql .= $limit;
        $this->setXmlNode('comments', 'comment');
        $qid = $this->db->query($sql);
        $split = '';
        $status = $this->mStatus->show($id);
        while ($rows = $this->db->fetch_array($qid)) {
            $member_ids .= $split . $rows['member_id'];
            $comment_array[$rows['id']] = $rows;
            $comment_array[$rows['id']]['status'] = $status[0];
            $split = ',';
        }
        $members = array();
        $members = $this->mUser->getUserById($member_ids);
        foreach ($comment_array as $k => $comment) {
            foreach ($members as $id => $user) {
                if ($comment['member_id'] == $user['id']) {
                    $comment['user'] = $user;
                }
            }
            $this->addItem($comment);
        }
        $this->output();
    }
}
$out = new comments();
$out->commentList();