Use where clause with Like in codeigniter
Posted
by
user2524013
on Stack Overflow
See other posts from Stack Overflow
or by user2524013
Published on 2013-06-29T22:19:17Z
Indexed on
2013/06/29
22:21 UTC
Read the original article
Hit count: 163
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.
© Stack Overflow or respective owner