Use where clause with Like in codeigniter
- by user2524013
I am working on a project. I am implementing the Search functionality in my System.
I will have to show the search record from two tables base on the current use login. I have tried the following code:
function searchActivity($limit,$offset,$keyword1,$keyword2,$recruiter_id)
{
$q=$this->db->select('*')->from('tbl_activity')->limit($limit,$offset);
$this->db->join('tbl_job', 'tbl_job.job_id = tbl_activity.job_id_fk', 'left outer');
$this->db->order_by("activity_id", "ASC");
$this->db->like('job_title',$keyword1,'both');
$this->db->or_like('job_title',$keyword2,'both');
$this->db->or_like('activity_subject',$keyword1,'both');
$this->db->or_like('activity_subject',$keyword2,'both');
$this->db->or_like('activity_details',$keyword1,'both');
$this->db->or_like('activity_details',$keyword2,'both');
$this->db->where('tbl_activity.recruiter_id_fk',$recruiter_id);
$ret['rows']=$q->get()->result();
return $ret;
}
I want to show search results based on the current user id, which is currently store in $recruiter.
Thanks in advance.