php - Failed to select data with where clause in array -


i have array $deptid :array(5) { [0]=> string(1) "2" [1]=> string(1) "8" [2]=> string(2) "11" [3]=> string(2) "15" [4]=> string(2) "17" } then, want select mysql database data deptid in array. query:

$deptdid = implode(',', $deptid); $this->db->select(*) ->from('tabel_data') ->where('deptid in ('.$deptid.')') ->group_by('deptid', 'asc') ->get(''): 

but error occur.

you have error in sql syntax; check manual corresponds mysql server version right syntax use near (array) group `deptid` @ line 6.  

maybe can give me solution

since you're using codeigniter can try using where_in function instead of implode , where. where_in method you.

$this->db->select(*) ->from('tabel_data') ->where_in('deptid', $deptid) ->group_by('deptid', 'asc') ->get(''): 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -