load->database(); $this->load->library('session'); } #--------------------------------------------------------------------------- # PURPOSE : list # CREATE : 2018-04-17 #--------------------------------------------------------------------------- function comment_parent_list($req_data){ # request $offset = $req_data['offset']; $limit = $req_data['limit']; $sort_column = $req_data['sort_column']; $sort_type = $req_data['sort_type']; $content_type = $req_data['content_type']; $content_idx = $req_data['content_idx']; $this->db->select('a.*, (select count(*) from comment where p_idx=a.idx and idx!=a.idx) as reply_count'); $this->db->where('a.content_type', $content_type); $this->db->where('a.content_idx', $content_idx); $this->db->where('a.s_idx', '1'); $this->db->from('comment as a'); $this->db->join('member as m', 'a.write_id=m.member_id', 'left'); $this->db->select('m.member_nickname, m.member_id'); $query = $this->db->get_compiled_select(); $this->db->from('('.$query.') as b'); $this->db->order_by('b.is_best', 'Desc'); $this->db->order_by('b.'.$sort_column, $sort_type); $this->db->limit($limit, $offset); $res = $this->db->get(); $row = $res->result_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : list # CREATE : 2018-04-20 #--------------------------------------------------------------------------- function comment_child_list($req_data){ # request $offset = $req_data['offset']; $limit = $req_data['limit']; $sort_column = $req_data['sort_column']; $sort_type = $req_data['sort_type']; $p_idx = $req_data['p_idx']; $this->db->where('a.p_idx', $p_idx); $this->db->where('a.s_idx > ', '1'); $this->db->from('comment as a'); $this->db->join('member m', 'a.write_id=m.member_id', 'left'); $this->db->select('a.*, m.member_nickname, m.member_id'); $this->db->limit($limit, $offset); $this->db->order_by('a.'.$sort_column, $sort_type); $res = $this->db->get(); $row = $res->result_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 글의 댓글 수 # CREATE : 2018-04-26 #--------------------------------------------------------------------------- function comment_parent_where_content_idx_count($req_data){ # request $content_type = $req_data['content_type']; $content_idx = $req_data['content_idx']; # request $this->db->where('content_type', $content_type); $this->db->where('content_idx', $content_idx); $this->db->where('s_idx', '1'); $this->db->from('comment'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 글의 댓글 수 # CREATE : 2018-04-26 #--------------------------------------------------------------------------- function comment_where_content_idx_count($req_data){ # request $content_type = $req_data['content_type']; $content_idx = $req_data['content_idx']; # request $this->db->where('content_type', $content_type); $this->db->where('content_idx', $content_idx); $this->db->from('comment'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 글의 내가 삭제한 댓글 수 # CREATE : 2018-04-26 #--------------------------------------------------------------------------- function comment_my_delete_where_content_idx_count($req_data){ # request $content_type = $req_data['content_type']; $content_idx = $req_data['content_idx']; $write_id = $req_data['write_id']; # request $this->db->where('content_type', $content_type); $this->db->where('content_idx', $content_idx); $this->db->where('write_id', $write_id); $this->db->where('is_del', 'Y'); $this->db->where('comment_status', '4'); $this->db->from('comment'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 1분 전 쓴글이 있는지 확인 # CREATE : 2018-04-27 #-------------------------------------------------------------------------- function comment_where_reg_date_count($req_data){ # request $write_id = $req_data['write_id']; $comment_sns_type = $req_data['comment_sns_type']; $reg_date = $req_data['reg_date']; # request $this->db->where('sns_name', $comment_sns_type); $this->db->where('write_id', $write_id); $this->db->where('is_del', 'N'); $this->db->where('reg_date >=', $reg_date); $this->db->from('comment'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : max idx # CREATE : 2018-04-27 #--------------------------------------------------------------------------- function comment_max_idx_select(){ # request $this->db->select('max(idx) + 1 as max_idx'); $this->db->from('comment'); $res = $this->db->get(); $row = $res->row_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : max s_idx # CREATE : 2018-04-27 #--------------------------------------------------------------------------- function comment_max_s_idx_select($idx){ # request $this->db->select('max(s_idx) + 1 as max_s_idx'); $this->db->where('idx', $idx); $this->db->from('comment'); $res = $this->db->get(); $row = $res->row_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : insert # CREATE : 2018-04-27 #--------------------------------------------------------------------------- function comment_insert($req_data){ $row = $this->db->insert('comment', $req_data); return $row; } #--------------------------------------------------------------------------- # PURPOSE : select # CREATE : 2018-04-27 #--------------------------------------------------------------------------- function comment_select($idx){ # request $this->db->select('*, (select count(*) from comment where p_idx=a.idx and idx!=a.idx) as reply_count'); $this->db->where('a.idx', $idx); $this->db->from('comment as a'); $res = $this->db->get(); $row = $res->row_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 대댓글수 # CREATE : 2018-04-27 #--------------------------------------------------------------------------- function comment_where_p_idx_count($p_idx){ # request $this->db->where('p_idx', $p_idx); $this->db->where('idx!=', $p_idx); $this->db->from('comment'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : update # CREATE : 2018-04-27 #--------------------------------------------------------------------------- function comemnt_like_bad_update($req_data){ # request $idx = $req_data['idx']; $type_name = $req_data['type_name']; $value = $req_data['value']; $sql = "update comment set ".$type_name." = ".$type_name." + ".$value." where idx= ".$idx; $row = $this->db->query($sql); return $row; } #--------------------------------------------------------------------------- # PURPOSE : list # CREATE : 2018-05-08 #--------------------------------------------------------------------------- function comment_join_vw_content_where_write_id_list($req_data){ # request $offset = $req_data['offset']; $limit = $req_data['limit']; $sort_column = $req_data['sort_column']; $sort_type = $req_data['sort_type']; $content_type = $req_data['content_type']; $write_id = $req_data['write_id']; $this->db->select('a.*, (select count(*) from comment where p_idx=a.idx and idx!=a.idx) as reply_count, b.title, b.main_img, b.column_name'); $this->db->where('a.content_type', $content_type); $this->db->where('a.write_id', $write_id); $this->db->where('b.is_del', 'N'); $this->db->where('b.is_display', 'Y'); $this->db->from('comment as a'); $this->db->join('vw_content as b', 'a.content_type=b.content_type and a.content_idx=b.idx'); $query = $this->db->get_compiled_select(); $this->db->from('('.$query.') as c'); if($sort_column == 'reply_count') { $this->db->order_by('c.s_idx', 'asc'); $this->db->order_by('c.'.$sort_column, $sort_type); } else { $this->db->order_by('c.is_best', 'desc'); $this->db->order_by('c.'.$sort_column, $sort_type); } $this->db->limit($limit, $offset); $res = $this->db->get(); $row = $res->result_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : user_comment count # CREATE : 2018-05-08 #--------------------------------------------------------------------------- function comment_join_vw_content_where_write_id_list_count($req_data){ # request $content_type = $req_data['content_type']; $write_id = $req_data['write_id']; # request $this->db->where('a.content_type', $content_type); $this->db->where('a.write_id', $write_id); $this->db->where('b.is_del', 'N'); $this->db->where('b.is_display', 'Y'); $this->db->from('comment as a'); $this->db->join('vw_content as b', 'a.content_type=b.content_type and a.content_idx=b.idx'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 내글 인지 확인 # CREATE : 2018-05-09 #--------------------------------------------------------------------------- function comment_member_id_idx_count($req_data){ # request $idx = $req_data['idx']; $write_id = $req_data['write_id']; # request $this->db->where('idx', $idx); $this->db->where('write_id', $write_id); $this->db->where('is_del', 'N'); $this->db->from('comment'); $row = $this->db->count_all_results(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : 내글 인지 확인 # CREATE : 2018-05-09 #--------------------------------------------------------------------------- function comment_member_id_idx_select($req_data){ # request $idx = $req_data['idx']; $write_id = $req_data['write_id']; # request $this->db->where('idx', $idx); $this->db->where('write_id', $write_id); $this->db->where('is_del', 'N'); $this->db->from('comment'); $res = $this->db->get(); $row = $res->row_array(); return $row; } #--------------------------------------------------------------------------- # PURPOSE : is_del update # CREATE : 2018-05-09 #--------------------------------------------------------------------------- function comment_is_del_update($req_data){ # request $idx = $req_data['idx']; unset($req_data['idx']); $this->db->where('idx', $idx); $row = $this->db->update('comment', $req_data); return $row; } } ?>