first commit
This commit is contained in:
193
application/models/admin/news/m_ranking.php
Executable file
193
application/models/admin/news/m_ranking.php
Executable file
@@ -0,0 +1,193 @@
|
||||
<?
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class m_ranking extends CI_Model{
|
||||
|
||||
// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
|
||||
$this->load->database();
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# PURPOSE : ranking news - list
|
||||
# CREATE : 2018-03-07
|
||||
#---------------------------------------------------------------------------
|
||||
function ranking_join_news_list($req_data){
|
||||
# request
|
||||
$offset = $req_data['offset'];
|
||||
$limit = $req_data['limit'];
|
||||
|
||||
$search_type = $req_data['search_type'];
|
||||
$search_keyword = $req_data['search_keyword'];
|
||||
$search_ranking_type = $req_data['search_ranking_type'];
|
||||
$search_category_code = $req_data['search_category_code'];
|
||||
$content_type = $req_data['content_type'];
|
||||
$sort_column = $req_data['sort_column'];
|
||||
|
||||
$search_click1 = '';
|
||||
if(isset($req_data['search_click1'])==true) $search_click1 = $req_data['search_click1'];
|
||||
|
||||
if($search_click1=='1') {
|
||||
$today_date = date("Y-m-d").' 00:00:00';
|
||||
$this->db->where('a.reg_date >=', $today_date);
|
||||
}
|
||||
|
||||
if($search_type!='' && $search_keyword!=''){
|
||||
$this->db->like('b.'.$search_type, $search_keyword);
|
||||
}
|
||||
if($search_ranking_type!='') $this->db->where('a.ranking_type', $search_ranking_type);
|
||||
if($search_category_code!='') $this->db->like('c.category_code', $search_category_code, 'after');
|
||||
|
||||
$this->db->select('a.idx, a.rank, a.title, a.main_img, a.ranking_type, a.content_idx, b.press_name, b.reporter_name, b.reg_date, b.is_display, b.display_date, b.hit_count, b.review_count1 as like_count, b.comment_count, b.share_count, c.category_code, c.category_name as category_name1');
|
||||
$this->db->where('a.content_type', $content_type);
|
||||
$this->db->where('a.is_del', 'N');
|
||||
$this->db->where('b.is_del', 'N');
|
||||
$this->db->where('c.is_del', 'N');
|
||||
$this->db->where('c.depth', '1');
|
||||
$this->db->from('ranking as a');
|
||||
$this->db->join('news as b', 'a.content_idx = b.idx');
|
||||
$this->db->join('news_section as c', 'SUBSTRING(b.category_code, 1, 2) = c.category_code');
|
||||
$this->db->order_by('b.display_date desc');
|
||||
$this->db->limit($limit, $offset);
|
||||
$this->db->order_by('b.'.$sort_column, 'desc');
|
||||
$res = $this->db->get();
|
||||
$row = $res->result_array();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# PURPOSE : ranking news - list - total count
|
||||
# CREATE : 2018-03-07
|
||||
#---------------------------------------------------------------------------
|
||||
function ranking_join_news_list_total_count($req_data){
|
||||
# request
|
||||
$search_type = $req_data['search_type'];
|
||||
$search_keyword = $req_data['search_keyword'];
|
||||
$search_ranking_type = $req_data['search_ranking_type'];
|
||||
$search_category_code = $req_data['search_category_code'];
|
||||
$content_type = $req_data['content_type'];
|
||||
|
||||
$search_click1 = '';
|
||||
if(isset($req_data['search_click1'])==true) $search_click1 = $req_data['search_click1'];
|
||||
|
||||
if($search_click1=='1') {
|
||||
$today_date = date("Y-m-d").' 00:00:00';
|
||||
$this->db->where('a.reg_date >=', $today_date);
|
||||
}
|
||||
|
||||
if($search_type!='' && $search_keyword!=''){
|
||||
$this->db->like('b.'.$search_type, $search_keyword);
|
||||
}
|
||||
if($search_ranking_type!='') $this->db->where('a.ranking_type', $search_ranking_type);
|
||||
if($search_category_code!='') $this->db->like('c.category_code', $search_category_code, 'after');
|
||||
|
||||
$this->db->where('a.content_type', $content_type);
|
||||
$this->db->where('a.is_del', 'N');
|
||||
$this->db->where('b.is_del', 'N');
|
||||
$this->db->where('c.is_del', 'N');
|
||||
$this->db->where('c.depth', '1');
|
||||
$this->db->from('ranking as a');
|
||||
$this->db->join('news as b', 'a.content_idx = b.idx');
|
||||
$this->db->join('news_section as c', 'SUBSTRING(b.category_code, 1, 2) = c.category_code');
|
||||
$row = $this->db->count_all_results();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# PURPOSE : ranking news - new count
|
||||
# CREATE : 2018-03-07
|
||||
#---------------------------------------------------------------------------
|
||||
function ranking_join_news_new_count($req_data){
|
||||
# request
|
||||
$search_type = $req_data['search_type'];
|
||||
$search_keyword = $req_data['search_keyword'];
|
||||
$search_ranking_type = $req_data['search_ranking_type'];
|
||||
$search_category_code = $req_data['search_category_code'];
|
||||
$content_type = $req_data['content_type'];
|
||||
|
||||
|
||||
$now_date = date("Y-m-d")." 00:00:00";
|
||||
|
||||
if($search_type!='' && $search_keyword!=''){
|
||||
$this->db->like('b.'.$search_type, $search_keyword);
|
||||
}
|
||||
if($search_ranking_type!='') $this->db->where('a.ranking_type', $search_ranking_type);
|
||||
if($search_category_code!='') $this->db->like('c.category_code', $search_category_code, 'after');
|
||||
|
||||
$this->db->where('a.content_type', $content_type);
|
||||
$this->db->where('a.is_del', 'N');
|
||||
$this->db->where('b.is_del', 'N');
|
||||
$this->db->where('b.is_del', 'N');
|
||||
$this->db->where('c.depth', '1');
|
||||
$this->db->from('ranking as a');
|
||||
$this->db->join('news as b', 'a.content_idx = b.idx');
|
||||
$this->db->join('news_section as c', 'SUBSTRING(b.category_code, 1, 2) = c.category_code');
|
||||
$this->db->where('a.reg_date >=', $now_date);
|
||||
$row = $this->db->count_all_results();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# PURPOSE : 랭킹 type list - select
|
||||
# CREATE : 2018-03-06
|
||||
#---------------------------------------------------------------------------
|
||||
function ranking_join_news_type_list($req_data){
|
||||
# request
|
||||
$content_type = $req_data['content_type'];
|
||||
$ranking_type = $req_data['ranking_type'];
|
||||
|
||||
$this->db->select('a.*, b.hit_count, b.review_count1, b.comment_count, b.press_name');
|
||||
$this->db->where('a.content_type', $content_type);
|
||||
$this->db->where('a.ranking_type', $ranking_type);
|
||||
$this->db->where('a.is_del', 'N');
|
||||
$this->db->where('b.is_del', 'N');
|
||||
$this->db->where('b.is_display', 'Y');
|
||||
$this->db->from('ranking as a');
|
||||
$this->db->join('news as b', 'a.content_idx = b.idx');
|
||||
$res = $this->db->get();
|
||||
$row = $res->result_array();
|
||||
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# PURPOSE : 랭킹 - select
|
||||
# CREATE : 2018-03-07
|
||||
#---------------------------------------------------------------------------
|
||||
function ranking_join_news_select($req_data){
|
||||
# request
|
||||
$idx = $req_data;
|
||||
|
||||
$this->db->select('a.*, b.hit_count, b.review_count1, b.comment_count, b.press_name');
|
||||
$this->db->where('a.idx', $idx);
|
||||
$this->db->where('a.is_del', 'N');
|
||||
$this->db->where('b.is_del', 'N');
|
||||
$this->db->from('ranking as a');
|
||||
$this->db->join('news as b', 'a.content_idx = b.idx');
|
||||
$res = $this->db->get();
|
||||
$row = $res->result_array();
|
||||
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user