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

330 lines
11 KiB
PHP
Executable File

<?
defined('BASEPATH') OR exit('No direct script access allowed');
class m_realtime_keyword extends CI_Model{
function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('session');
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 - list
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_list(){
$this->db->where('is_del', 'N');
$this->db->from('realtime_keyword');
$this->db->order_by('rank asc');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 - list where search count
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function realtime_keyword_list_where_search_count($req_data){
# request
$search_count = $req_data;
$this->db->where('is_del', 'N');
$this->db->where('search_count <=', $search_count);
$this->db->from('realtime_keyword');
$this->db->order_by('rank asc');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 - list where search count 위에 순위
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function realtime_keyword_list_where_over_search_count($req_data){
# request
$search_count = $req_data;
$this->db->where('is_del', 'N');
$this->db->where('search_count >', $search_count);
$this->db->from('realtime_keyword');
$this->db->order_by('rank desc');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 insert
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_insert($req_data){
# request
$rank = $req_data['rank'];
$keyword = $req_data['keyword'];
$search_count = $req_data['search_count'];
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$insert_data = array('rank' => $rank,
'keyword' => $keyword,
'search_count' => $search_count,
'reg_id' => $user_id,
'reg_date' => $now_date,
'update_id' => $user_id,
'update_date' => $now_date
);
$row = $this->db->insert('realtime_keyword', $insert_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 - realtime_keyword.is_del update
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_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('realtime_keyword', $arr_update_data, 'idx');
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 update
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_update($req_data){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
foreach($req_data as $key=>$val) {
$req_data[$key]['update_id'] = $user_id;
$req_data[$key]['update_date'] = $now_date;
}
$row = $this->db->update_batch('realtime_keyword', $req_data, 'idx');
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 셋팅 - select
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_setting_select($req_data){
# request
$idx = $req_data;
$this->db->where('idx', $idx);
$this->db->from('realtime_keyword_setting');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 select
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_where_keyword_select($keyword){
$this->db->where('keyword', $keyword);
$this->db->from('realtime_keyword');
$res = $this->db->get();
$row = $res->row_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 셋팅 - update
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function realtime_keyword_setting_update($req_data){
# request
$idx = $req_data['idx'];
$base_hour = $req_data['base_hour'];
$delete_hour = $req_data['delete_hour'];
$is_no_result_keyword = $req_data['is_no_result_keyword'];
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$update_data = array('base_hour' => $base_hour,
'delete_hour' => $delete_hour,
'is_no_result_keyword' => $is_no_result_keyword,
'update_id' => $user_id,
'update_date' => $now_date
);
$this->db->where('idx', $idx);
$row = $this->db->update('realtime_keyword_setting', $update_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 log - list
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function realtime_keyword_log_list($req_data){
# request
$start_date = $req_data['start_date'];
$end_date = $req_data['end_date'];
$offset = $req_data['offset'];
$limit = $req_data['limit'];
$this->db->where('base_date >=', $start_date);
$this->db->where('base_date <=', $end_date);
$this->db->where('is_del', 'N');
$this->db->from('realtime_keyword_log');
$this->db->order_by('reg_date desc, rank asc');
$this->db->limit($limit, $offset);
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 log list - total count
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function realtime_keyword_log_list_total_count($req_data){
# request
$start_date = $req_data['start_date'];
$end_date = $req_data['end_date'];
$this->db->where('base_date >=', $start_date);
$this->db->where('base_date <=', $end_date);
$this->db->where('is_del', 'N');
$this->db->from('realtime_keyword_log');
$row = $this->db->count_all_results();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 log - all list
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function realtime_keyword_log_all_list($req_data){
# request
$start_date = $req_data['start_date'];
$end_date = $req_data['end_date'];
$this->db->where('base_date >=', $start_date);
$this->db->where('base_date <=', $end_date);
$this->db->where('is_del', 'N');
$this->db->from('realtime_keyword_log');
$this->db->order_by('reg_date desc, rank asc');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 실시간검색어 select max reg_date
# CREATE : 2018-03-27
#---------------------------------------------------------------------------
function realtime_keyword_max_reg_date(){
$this->db->select('max(reg_date) as reg_date');
$this->db->where('is_del', 'N');
$this->db->from('realtime_keyword');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 로그로 이동
# CREATE : 2018-03-27
#---------------------------------------------------------------------------
function realtime_keyword_move_log(){
$now_date = date("Y-m-d H:i:s");
$sql = "INSERT INTO realtime_keyword_log (base_date, rank, last_rank, keyword, search_count, reg_id, reg_date, update_id, update_date, is_del)
SELECT reg_date, rank, last_rank, keyword, search_count, reg_id, reg_date, update_id, update_date, is_del
FROM realtime_keyword";
$this->db->query($sql);
}
#---------------------------------------------------------------------------
# PURPOSE : delete
# CREATE : 2018-04-17
#---------------------------------------------------------------------------
function realtime_keyword_where_reg_date_delete($reg_date){
$this->db->where('reg_date <', $reg_date);
$row = $this->db->delete('realtime_keyword');
return $row;
}
}
?>