<?php 
class gallery_model extends CI_model
 {
   
	

		function get_imgs($type,$post_id,$rec_no)
		{
		  $this->db->where('post_type',$type);
		  $this->db->where('post_id',$post_id); 
		  
		  $query=$this->db->get('gallery',$rec_no,$this->uri->segment(6)); // select * from gallery where post_type='$type'  limit $rec_no
		  
		  if($query->num_rows() > 0)
		    return $query->result(); 
		     return FALSE;

		}
		
		function get_num_imgs($type,$post_id)
		{
		  $this->db->where('post_type',$type);
		  $this->db->where('post_id',$post_id);

		  $query=$this->db->get('gallery'); // select * from gallery where post_type='$type' ...
		  
		  if($query->num_rows() > 0)
		    return $query->num_rows(); 
		     return FALSE;

		}

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

}
