mysql - Codeigniter query builder using implode function in where_in -
here normal sql query using implode function:
select * search_result skills in ('".implode("','",$s_id)."');
now want convert codeigniter form. tried following code fails
$this->db->from('search_result'); $this->db->where_in('skills','".implode("','",$s_id)."'); $query = $this->db->get();
here $s_id
array:
array ( [0] => 2d design [1] => 3d design [2] => 3d modelling )
so please me this. in advance :)
official doc say's
$names = array('frank', 'todd', 'james'); # data array $this->db->where_in('username', $names); # passing array
try below
method 01(recommended )
$this->db->from('search_result'); $this->db->where_in('skills',$s_id); $query = $this->db->get();
method 02
$this->db->from('search_result'); $this->db->where_in('skills',implode("','",$s_id)); $query = $this->db->get();
whats wrong on line
$this->db->where_in('skills','".implode("','",$s_id)."');
don't wrap function '
or "
quotes. save string value db.
links
Comments
Post a Comment