<?php 
class Comment_Model extends Model{
	function __construct(){
		parent::__construct();
	}
	function delete($ids){
		return $this->db->in("id",$ids)->delete("comment");
	}
	function update($id,$data){
		$this->db->where("id",$id);
		return $this->db->update("comment",$data);
	}
	function get($page=1,$showlines=20){
		$sql	=	"
		SELECT `sc`.`title`, `m`.`user_name`, `c`.* 
		FROM `".DBFIX."comment` AS `c` 
		LEFT JOIN `".DBFIX."search_cache` AS `sc` ON (`sc`.`content_id` = `c`.`conid`) 
		LEFT JOIN `".DBFIX."member` AS `m` ON (`m`.`user_id` = `c`.`userid`) 
		WHERE `sc`.`channel_id`=`c`.`channelid`
		ORDER BY `c`.`dtime` DESC LIMIT ".($page*$showlines-$showlines).",$showlines";
		return $this->db->query($sql);
	}
	function getComment($id){
		$this->db->where("id",$id);
		$this->db->join("member as m","m.user_id","c.userid","left");
		return $this->db->get("comment as c")->current();
	}
}