<?php
/* 
 * Generated by CRUDigniter v3.2 
 * www.crudigniter.com
 */
 
class Comentarioqueja_model extends CI_Model
{
    function __construct()
    {
        parent::__construct();
    }
    
    /*
     * Get comentarioqueja by id
     */
    function get_comentarioqueja($id)
    {
        return $this->db->get_where('comentarioqueja',array('id'=>$id))->row_array();
    }
    
    /*
     * Get all comentariosquejas count
     */
    function get_all_comentariosquejas_count()
    {
        $this->db->from('comentarioqueja');
        return $this->db->count_all_results();
    }

    /*
     * Get all comentariosquejas count of queja
     */
    function get_all_comentariosquejas_count_of_queja($id_queja)
    {
        $this->db->where('id_queja',$id_queja);
        $this->db->from('comentarioqueja');
        return $this->db->count_all_results();
    }
        
    /*
     * Get all comentariosquejas
     */
    function get_all_comentariosquejas($params = array())
    {
        $this->db->order_by('id', 'desc');
        if(isset($params) && !empty($params))
        {
            $this->db->limit($params['limit'], $params['offset']);
        }
        return $this->db->get('comentarioqueja')->result_array();
    }

    /*
     * Get all comentariosquejas by queja
     */
    function get_all_comentariosquejas_of_queja($id_queja, $params = array())
    {
        $this->db->where('id_queja',$id_queja);
        $this->db->order_by('id', 'desc');
        if(isset($params) && !empty($params))
        {
            $this->db->limit($params['limit'], $params['offset']);
        }
        return $this->db->get('comentarioqueja')->result_array();
    }

    /*
     * function to add new comentarioqueja
     */
    function add_comentarioqueja($params)
    {
        $this->db->insert('comentarioqueja',$params);
        return $this->db->insert_id();
    }
    
    /*
     * function to update comentarioqueja
     */
    function update_comentarioqueja($id,$params)
    {
        $this->db->where('id',$id);
        return $this->db->update('comentarioqueja',$params);
    }
    
    /*
     * function to delete comentarioqueja
     */
    function delete_comentarioqueja($id)
    {
        return $this->db->delete('comentarioqueja',array('id'=>$id));
    }
}
