<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	
	class Mod_search extends CI_Model{
		
		function get_results($search_term='default',$p=1,$id="")
		{
			// Use the Active Record class for safer queries.
			$this->db->select('*');
			$this->db->from('blog_posts');
			$this->db->like('postTitle',$search_term);
			
			if($p==1)
			{
				$start=0;	
			}else{
				$start=($p*10)-10;			
			}
			
			$count=10;
			if($id=="")
			{
				$this->db->limit($count,$start);
			} 	
			
			return $this->db->get();
			
		}
		
		function search_countAll($search_term)
		{
			$this->db->like("postTitle",$search_term);
			return $this->db->count_all_results('blog_posts');
				
		}
		
		function getdata($data)
		{
			$this->db->like('postTitle',$data);
			$this->db->order_by('postID');
			$this->db->from('blog_posts');
			$this->db->limit(5);
			$q = $this->db->get();
			if($q->num_rows() > 0)
			{
				//return $q->row();
				return $q;
			}
			return false;
		}
		
	}