<?php 
class categories_model extends CI_model
 {
   
	

		function get_categories($type,$rec_no)
		{
		  $this->db->where('module',$type);
		  
		  $this->db->order_by("id", "desc"); 
		  $query=$this->db->get('categories',$rec_no,$this->uri->segment(4)); // select * from posts where module='$type'  limit $rec_no
		  
		  if($query->num_rows() > 0)
		    return $query->result(); 
		     return FALSE;

		}
		
		function get_num_cats($type)
		{
		  $this->db->where('module',$type);
		  $query=$this->db->get('categories'); // select * from posts where module='$type' 
		  if($query->num_rows() > 0)
		    return $query->num_rows(); 
		     return FALSE;
		}

		
		
		function add_new_category($data)
		{
		$q=$this->db->insert('categories',$data);
		return $q;
		}
		
		function update_category($data,$id)
		{
		$this->db->where('id',$id);
		$q=$this->db->update('categories',$data);
		//if($q->num_rows() > 0)
		return $q; 
		//return FALSE;
		}
	
	
	

}
