327 lines
12 KiB
PHP
Executable File
327 lines
12 KiB
PHP
Executable File
<?
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class m_life extends CI_Model{
|
|
|
|
// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
|
|
function __construct(){
|
|
parent::__construct();
|
|
|
|
$this->load->database();
|
|
$this->load->library('session');
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : life - list
|
|
# CREATE : 2018-04-11
|
|
#---------------------------------------------------------------------------
|
|
function life_list($req_data){
|
|
# request
|
|
$offset = $req_data['offset'];
|
|
$limit = $req_data['limit'];
|
|
$sort_column = $req_data['sort_column'];
|
|
|
|
$start_date = ''; $end_date = ''; $search_type =''; $search_key = ''; $search_keyword = '';
|
|
if(isset($req_data['start_date']) == true) $start_date = $req_data['start_date'];
|
|
if(isset($req_data['end_date']) == true) $end_date = $req_data['end_date'];
|
|
if(isset($req_data['search_type']) == true) $search_type = $req_data['search_type'];
|
|
if(isset($req_data['search_key']) == true) $search_key = $req_data['search_key'];
|
|
if(isset($req_data['search_keyword']) == true) $search_keyword = $req_data['search_keyword'];
|
|
|
|
if($search_type == 'main_search' && $search_keyword!='') $this->db->where("match(a.title, a.content, a.tag) against('".$search_keyword."' in boolean mode)");
|
|
if($search_type == 'main_search_and_video_url' && $search_keyword!='') {
|
|
$this->db->where("match(a.title, a.content, a.tag) against('".$search_keyword."' in boolean mode)");
|
|
$this->db->where('a.video_url!=', '');
|
|
}
|
|
if($search_type != '' && $search_key!='') $this->db->where('a.'.$search_type, $search_key);
|
|
if($start_date != '') $this->db->where('a.display_date >=', $start_date);
|
|
if($end_date != '') $this->db->where('a.display_date <=', $end_date);
|
|
|
|
$this->db->select('a.*, "3" as content_type, b.partner_img, (select category_name from category where a.category_idx = idx) as category_name');
|
|
$this->db->where('a.is_del', 'N');
|
|
$this->db->where('a.is_display', 'Y');
|
|
$this->db->from('life as a');
|
|
$this->db->join('partner as b', 'a.partner_idx=b.idx');
|
|
$this->db->limit($limit, $offset);
|
|
$this->db->order_by('a.'.$sort_column, 'desc');
|
|
$this->db->order_by('a.display_date', 'desc');
|
|
$res = $this->db->get();
|
|
$row = $res->result_array();
|
|
|
|
return $row;
|
|
}
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : life - list - total count
|
|
# CREATE : 2018-04-11
|
|
#---------------------------------------------------------------------------
|
|
function life_list_total_count($req_data){
|
|
|
|
$start_date = ''; $end_date = ''; $search_type =''; $search_key = '';
|
|
if(isset($req_data['start_date']) == true) $start_date = $req_data['start_date'];
|
|
if(isset($req_data['end_date']) == true) $end_date = $req_data['end_date'];
|
|
if(isset($req_data['search_type']) == true) $search_type = $req_data['search_type'];
|
|
if(isset($req_data['search_key']) == true) $search_key = $req_data['search_key'];
|
|
if(isset($req_data['search_keyword']) == true) $search_keyword = $req_data['search_keyword'];
|
|
|
|
|
|
if($start_date != '') $this->db->where('display_date >=', $start_date);
|
|
if($end_date != '') $this->db->where('display_date <=', $end_date);
|
|
if($search_type != '' && $search_key!='') $this->db->where($search_type, $search_key);
|
|
if($search_type == 'main_search' && $search_keyword!='') $this->db->where("match(title, content, tag) against('".$search_keyword."' in boolean mode)");
|
|
|
|
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$row = $this->db->count_all_results();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : join select
|
|
# CREATE : 2018-04-11
|
|
#---------------------------------------------------------------------------
|
|
function life_join_editor_category_channel_select($idx){
|
|
|
|
$this->db->select('a.*, b.partner_img, c.category_name, d.channel_name, d.main_img as channel_main_img');
|
|
$this->db->where('a.idx', $idx);
|
|
$this->db->where('a.is_del', 'N');
|
|
$this->db->where('c.is_del', 'N');
|
|
$this->db->where('d.is_del', 'N');
|
|
$this->db->where('a.is_display', 'Y');
|
|
$this->db->from('life as a');
|
|
$this->db->join('partner as b', 'a.partner_idx=b.idx');
|
|
$this->db->join('category as c', 'a.category_idx=c.idx');
|
|
$this->db->join('channel as d', 'a.channel_idx=d.idx');
|
|
|
|
$res = $this->db->get();
|
|
$row = $res->row_array();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : prev select
|
|
# CREATE : 2018-04-11
|
|
#---------------------------------------------------------------------------
|
|
function life_prev_select($idx){
|
|
|
|
$this->db->where('idx <', $idx);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$this->db->order_by('display_date', 'desc');
|
|
$this->db->limit(1);
|
|
|
|
$res = $this->db->get();
|
|
$row = $res->row_array();
|
|
|
|
|
|
return $row;
|
|
}
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : next select
|
|
# CREATE : 2018-04-11
|
|
#---------------------------------------------------------------------------
|
|
function life_next_select($idx){
|
|
|
|
$this->db->where('idx >', $idx);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->order_by('display_date', 'asc');
|
|
$this->db->from('life');
|
|
$this->db->limit(1);
|
|
|
|
$res = $this->db->get();
|
|
$row = $res->row_array();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : update
|
|
# CREATE : 2018-04-17
|
|
#---------------------------------------------------------------------------
|
|
function life_like_count_update($req_data){
|
|
# request
|
|
$idx = $req_data['idx'];
|
|
$value = $req_data['value'];
|
|
|
|
$sql = "update life
|
|
set like_count = like_count + ".$value."
|
|
where idx= ".$idx;
|
|
$row = $this->db->query($sql);
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : select
|
|
# CREATE : 2018-04-17
|
|
#---------------------------------------------------------------------------
|
|
function life_select($idx){
|
|
|
|
$this->db->select('*, (select category_name from category where life.category_idx = idx) as category_name');
|
|
$this->db->where('idx', $idx);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$res = $this->db->get();
|
|
$row = $res->row_array();
|
|
|
|
return $row;
|
|
}
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : select
|
|
# CREATE : 2018-04-17
|
|
#---------------------------------------------------------------------------
|
|
function life_select_idx($idx){
|
|
$this->db->where('idx', $idx);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$res = $this->db->get();
|
|
$row = $res->row_array();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : hit +1 update
|
|
# CREATE : 2018-04-26
|
|
#---------------------------------------------------------------------------
|
|
function life_hit_count_update($idx){
|
|
|
|
$sql = "update life
|
|
set hit_count = hit_count + 1
|
|
where idx= ".$idx;
|
|
$row = $this->db->query($sql);
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : update
|
|
# CREATE : 2018-04-28
|
|
#---------------------------------------------------------------------------
|
|
function life_share_count_update($req_data){
|
|
# request
|
|
$idx = $req_data['idx'];
|
|
$value = $req_data['value'];
|
|
|
|
$sql = "update life
|
|
set share_count = share_count + ".$value."
|
|
where idx= ".$idx;
|
|
$row = $this->db->query($sql);
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : life where channel_idx
|
|
# CREATE : 2018-05-07
|
|
#---------------------------------------------------------------------------
|
|
function life_where_channel_idx_list_limit1($req_data){
|
|
# request
|
|
$channel_idx = $req_data['channel_idx'];
|
|
|
|
$this->db->where('channel_idx', $channel_idx);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$this->db->limit(1, 0);
|
|
$this->db->order_by('display_date', 'desc');
|
|
$res = $this->db->get();
|
|
$row = $res->row_array();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : life where now_date
|
|
# CREATE : 2018-05-07
|
|
#---------------------------------------------------------------------------
|
|
function life_where_display_date_count($req_data){
|
|
# request
|
|
$reg_date = $req_data;
|
|
|
|
$this->db->where('display_date >=', $reg_date);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$row = $this->db->count_all_results();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : comment_count +1 update
|
|
# CREATE : 2018-05-11
|
|
#---------------------------------------------------------------------------
|
|
function life_comment_count_update($idx){
|
|
|
|
$sql = "update life
|
|
set comment_count = comment_count + 1
|
|
where idx= ".$idx;
|
|
$row = $this->db->query($sql);
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
# PURPOSE : life where now_date + channle_idx
|
|
# CREATE : 2018-05-30
|
|
#---------------------------------------------------------------------------
|
|
function life_where_display_date_channel_idx_count($req_data){
|
|
# request
|
|
$now_date = $req_data['now_date'];
|
|
$channel_idx = $req_data['channel_idx'];
|
|
|
|
$this->db->where('channel_idx', $channel_idx);
|
|
$this->db->where('display_date >=', $now_date);
|
|
$this->db->where('is_del', 'N');
|
|
$this->db->where('is_display', 'Y');
|
|
$this->db->from('life');
|
|
$row = $this->db->count_all_results();
|
|
|
|
return $row;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|