0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
marketting
/
system
/
application
/
models
/
[
Home
]
File: faq_cat_model.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | COPYRIGHT NOTICE | Copyright 2008 JROX Technologies, Inc. All Rights Reserved. | ------------------------------------------------------------------------- | This script may be only used and modified in accordance to the license | agreement attached (license.txt) except where expressly noted within | commented areas of the code body. This copyright notice and the | comments above and below must remain intact at all times. By using this | code you agree to indemnify JROX Technologies, Inc, its corporate agents | and affiliates from any liability that might arise from its use. | | Selling the code for this program without prior written consent is | expressly forbidden and in violation of Domestic and International | copyright laws. | | ------------------------------------------------------------------------- | FILENAME - faq_model.php | ------------------------------------------------------------------------- | | This model handles the functions for managing faq | */ class faq_Cat_Model extends Model { function _add_faq_category() { $data = $this->db_validation_model->_clean_data($_POST); //insert into db if (!$this->db->insert('faq_categories', $data)) { show_error($this->lang->line('could_not_add_category')); //log error log_message('error', 'Could not insert category into faq table'); return false; } else { $id = $this->db->insert_id(); //log success log_message('info', 'category '. $id . ' inserted into faq_categories table'); } return $id; } // ------------------------------------------------------------------------ function _delete_faq_category($id = '') { if ($id == 1) { return false; } //update articles first $sdata = array('category_id' => '0'); $this->db->where('category_id', $id); $this->db->update('faq_articles', $sdata); //delete faq $this->db->where('category_id', $id); if ($this->db->delete('faq_categories')) { //log success log_message('info', 'category ID #' . $id . ' deleted successfully'); } else { show_error($this->lang->line('could_not_delete_faq_category')); //log error log_message('error', 'category ID #' . $id . ' could not be deleted'); } return true; } // ------------------------------------------------------------------------ function _get_faq_category_details($id = '') { //get the data from faq table $this->db->where('category_id', $id); $query = $this->db->get('faq_categories'); if ($query->num_rows() > 0) { return $query->result_array(); } else { return false; } } // ------------------------------------------------------------------------ function _get_faq_categories($limit = 25, $offset = 0, $sort_column = '', $sort_order = '') { //get all the admins from db for list view if (!$sort_order) $sort_order = $this->config->item('dbs_coc_order'); if (!$sort_column) $sort_column = $this->config->item('dbs_coc_column'); $sql = 'SELECT ' . $this->db->dbprefix('faq_categories') . '.* FROM ' . $this->db->dbprefix('faq_categories') . ' ORDER BY ' . $sort_column . ' ' . $sort_order . ' LIMIT ' . $offset. ', ' . $limit; $query = $this->db->query($sql); if ($query->num_rows() > 0) { return $query->result_array(); } return false; } // ------------------------------------------------------------------------ function _update_faq_category($id = '') { //clean the data first $data = $this->db_validation_model->_clean_data($_POST); //update faq data $this->db->where('category_id', $id); if (!$this->db->update('faq_categories', $data)) { show_error($this->lang->line('could_not_update_faq_category')); //log error log_message('error', 'Could not update category ID ' . $id . 'in faq_categories table'); return false; } else { //log success log_message('info', 'category ID '. $id . ' updated in faq_categories table'); } return true; } // ------------------------------------------------------------------------ } ?>