/** * 게시판 데이터 입력 * @param array (POST내용) * @param string (원글0, 답글은 원글번호) * @return int */ function insert_board($post, $type, $user_id, $username) { $general_setting = ''; $this_date = date("Y-m-d H:i:s"); //원글, 답글 처리 //no 유니크번호, board_pid 게시물 순차번호, reply_order 답글 정렬순서 if ($type == '0') { //원글 $this->db->select_max('board_pid'); $this->db->where('is_delete', 'N'); $query = $this->db->get($this->table); $board_pids = $query->row(); $board_pid = $board_pids->board_pid + 1; $reply_order_no = 0; //echo $this->db->last_query(); } else { if ($type > '0') { //답글 $this->db->select('board_pid, reply_order'); $this->db->where('is_delete', 'N'); $this->db->where('board_pid', $type); $this->db->order_by('reply_order', 'desc'); $query = $this->db->get($this->table); $board_pids = $query->row(); $board_pid = $board_pids->board_pid; $reply_order_no = $board_pids->reply_order + 1; } } //print_r($board_pid); $file_count = '0'; $data = array('table_id' => MENU_ID, 'board_pid' => $board_pid, 'user_id' => $user_id, 'user_name' => $username, 'reg_date' => $this_date, 'modify_date' => $this_date, 'is_secret' => '', 'subject' => $this->security->xss_clean($post['subject']), 'general_setting' => $general_setting, 'contents' => $post['contents'], 'files_count' => $file_count, 'download_count' => '0', 'scrap_count' => '0', 'hit' => '0', 'comment_count' => '0', 'reply_count' => '0', 'voted_count' => '0', 'blamed_count' => '0', 'ip' => $this->input->ip_address(), 'password' => @$post['password'], 'reply_order' => $reply_order_no); //print_r($data); $this->db->insert($this->table, $data); $last_id = big_last_id(); //답글일 경우 답글 수 + 처리 if ($type > '0') { //$this->db->set('comment_count', 'comment_count+1', FALSE); $this->db->set('reply_count', 'reply_count+1', FALSE); $this->db->where(array('board_pid' => $type, 'reply_order' => '0', 'is_delete' => 'N')); $this->db->update($this->table); } //태그처리 //echo $last_id; if ($post['tags']) { $tag_arr = explode(",", $this->security->xss_clean($post['tags'])); $cnt = count($tag_arr); for ($i = 0; $i < $cnt; $i++) { $tagss = array('module_name' => MENU_ID, 'parent_no' => $last_id, 'tag_name' => trim($tag_arr[$i]), 'reg_date' => $this_date); $this->db->insert($this->tags_table, $tagss); } } //첨부파일 DB 입력 $file_cnt = $this->common->strip_image_tags_fck($post['contents'], $last_id, '', $this->table, MENU_ID); //글내용, 게시글번호, 타입(있으면 리플, 테이블명, 테이블번호) //파일갯수 업데이트 $data_file = array('files_count ' => $file_cnt); $this->db->where('id', $last_id); $this->db->update($this->table, $data_file); return $last_id; }
/** * Create new user record * * @param array * @param bool * @return array */ function create_user($data, $activated = TRUE) { $data['created'] = date('Y-m-d H:i:s'); $data['activated'] = $activated ? 1 : 0; if ($this->db->insert($this->table_name, $data)) { $user_id = big_last_id(); if ($activated) { $this->create_profile($user_id); } return array('user_id' => $user_id); $arr = array('user_id' => $user_id); $this->db->insert('user_profiles', $arr); } return NULL; }
/** * 클라이언트 등록 * */ function set_user($usr, $adv) { if (count($usr) > 0) { $this->db->insert('users', $usr); $last_id = big_last_id(); } $adv['user_id'] = $last_id; if (count($adv) > 0) { $this->db->insert('client', $adv); } return $last_id; }