[eluser]Thorpe Obazee[/eluser]
Code:
function search($limit, $offset = FALSE)
{
$this->db->select('jobs.id as job_id, jobs.job_name, jobs.job_title as job_title, jobs.job_content, jobs.job_author, jobs.job_posted as job_posted, jobs.cat_id, jobs.job_status, cats.id as cat_id, cats.cat_title');
$this->db->from('jobs');
$this->db->join('cats','cats.id = jobs.cat_id');
if (isset($this->keyword))
{
$this->db->like('jobs.job_title',$this->keyword);
}
if ($offset)
{
$this->db->limit($limit,$offset);
}
else
{
$this->db->limit($limit);
}
$this->db->order_by('job_posted');
$query = $this->db->get();
return $query;
}
function count_result()
{
$this->db->select('count(jobs.id) as job_count');
$this->db->from('jobs');
$this->db->join('cats','cats.id = jobs.cat_id');
if (isset($this->keyword))
{
$this->db->like('jobs.job_title',$this->keyword);
}
$this->db->order_by('job_posted');
$query = $this->db->count_all_results();
return $query;
}
I believe this works since I also use it for another pagination. But then again.. I may be missing something.