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

164 lines
5.4 KiB
PHP
Executable File

<?
defined('BASEPATH') OR exit('No direct script access allowed');
class m_today_word extends CI_Model{
// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('session');
}
#---------------------------------------------------------------------------
# PURPOSE : 오늘의말씀 - list
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function today_word_list($req_data){
# request
$offset = $req_data['offset'];
$limit = $req_data['limit'];
$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->from('today_word')->order_by('display_date', 'desc');
$this->db->limit($limit, $offset);
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 오늘의말씀 - list - total count
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function today_word_list_total_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->from('today_word');
$row = $this->db->count_all_results();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 오늘의말씀 - insert
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function today_word_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('today_word', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 오늘의말씀 - update
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function today_word_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('today_word', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 오늘의말씀 - select
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function today_word_select($req_data){
# request
$idx = $req_data;
$this->db->where('idx', $idx);
$this->db->where('is_del', 'N');
$this->db->from('today_word');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 오늘의말씀 is_del update
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function today_word_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('today_word', $arr_update_data, 'idx');
}
#---------------------------------------------------------------------------
# PURPOSE : 예약글 업데이트
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function today_word_reservation_update(){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$display_now_date = date("Y-m-d");
$req_data['is_display'] = 'Y';
$req_data['update_id'] = $user_id;
$req_data['update_date'] = $now_date;
$this->db->where('is_del', 'N');
$this->db->where('is_display', 'N');
$this->db->where('display_date<=', $display_now_date);
$row = $this->db->update('today_word', $req_data);
return $row;
}
}
?>