Files
cm-web-legacy/application/models/admin/etc_section/m_press.php
2020-06-10 06:19:03 +09:00

234 lines
7.7 KiB
PHP
Executable File

<?
defined('BASEPATH') OR exit('No direct script access allowed');
class m_press extends CI_Model{
// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('session');
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - list
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function press_list($req_data){
# request
$offset = $req_data['offset'];
$limit = $req_data['limit'];
$search_type = $req_data['search_type'];
$search_keyword = $req_data['search_keyword'];
$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') $this->db->like('is_direct', 'Y');
if($search_type!='' && $search_keyword!=''){
$this->db->like($search_type, $search_keyword);
}
$this->db->where('is_del', 'N');
$this->db->from('press');
$this->db->order_by($sort_column, 'desc');
$this->db->limit($limit, $offset);
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - list - total count
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function press_list_total_count($req_data){
# request
$search_type = $req_data['search_type'];
$search_keyword = $req_data['search_keyword'];
$search_click1 = '';
if(isset($req_data['search_click1'])==true) $search_click1 = $req_data['search_click1'];
if($search_click1=='1') $this->db->like('is_direct', 'Y');
if($search_type!='' && $search_keyword!=''){
$this->db->like($search_type, $search_keyword);
}
$this->db->where('is_del', 'N');
$this->db->from('press');
$row = $this->db->count_all_results();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - all list
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function press_all_list(){
$this->db->where('is_del', 'N');
$this->db->from('press');
$this->db->order_by('reg_date', 'asc');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - 바로가기 count
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function press_is_direct_list_count($req_data){
# request
$search_type = $req_data['search_type'];
$search_keyword = $req_data['search_keyword'];
if($search_type!='' && $search_keyword!=''){
$this->db->like($search_type, $search_keyword);
}
$this->db->where('is_del', 'N');
$this->db->where('is_direct', 'Y');
$this->db->from('press');
$row = $this->db->count_all_results();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - insert
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function press_insert($req_data){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$req_data['reg_id'] = $user_id;
$req_data['reg_date'] = $now_date;
$req_data['update_id'] = $user_id;
$req_data['update_date']= $now_date;
$row = $this->db->insert('press', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - select
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function press_select($req_data){
# request
$idx = $req_data;
$this->db->where('idx', $idx);
$this->db->where('is_del', 'N');
$this->db->from('press');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - update
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function press_update($req_data){
# request
$idx = $req_data['idx'];
unset($req_data['idx']);
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$req_data['update_id'] = $user_id;
$req_data['update_date'] = $now_date;
$this->db->where('idx', $idx);
$row = $this->db->update('press', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - update_batch
# CREATE : 2018-03-22
#---------------------------------------------------------------------------
function press_article_count_update($req_data){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$arr_update_data = array();
foreach($req_data as $key=>$val) {
if($val['press_idx']=='') continue;
$arr_update_data[$key]['idx'] = $val['press_idx'];
$arr_update_data[$key]['article_count'] = $val['cnt'];
$arr_update_data[$key]['update_id'] = $user_id;
$arr_update_data[$key]['update_date'] = $now_date;
}
$row = $this->db->update_batch('press', $arr_update_data, 'idx');
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 is_del update
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function press_is_del_update($req_data){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$arr_update_data = array();
foreach($req_data as $key=>$val) {
$arr_update_data[$key]['idx'] = $val;
$arr_update_data[$key]['is_del'] = 'Y';
$arr_update_data[$key]['update_id'] = $user_id;
$arr_update_data[$key]['update_date'] = $now_date;
}
$this->db->update_batch('press', $arr_update_data, 'idx');
}
#---------------------------------------------------------------------------
# PURPOSE : 언론사 - select in idx
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function press_select_in_idx($req_data){
# request
$arr_idx = $req_data;
$this->db->where_in('idx', $arr_idx);
$this->db->where('is_del', 'N');
$this->db->from('press');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
}
?>