Welcome Guest, Not a member yet? Register   Sign In
where_in method unexpected query
#1

Hi,
I have a query like this
Code:
$this->db->where_in('chat_session', $latest_sessions)->update('chat_state', $update_state);

which generating following result

UPDATE `chat_state` SET `status` = 'exit'
WHERE `chat_session` IN('55_6_11,30_6_2')

But I need following query
UPDATE `chat_state` SET `status` = 'exit'
WHERE `chat_session` IN('55_6_11','30_6_2')

I have tried following still not working
Code:
$this->db->where_in('chat_session', $latest_sessions,NULL)->update('chat_state', $update_state);

and

Code:
$this->db->where_in('chat_session', $latest_sessions,FALSE)->update('chat_state', $update_state);
The largest Bengali tutorial site on Web Development in this planet
Reply
#2

is $latest_sessions an array? or is a string?. Do an echo. Does it output: '55_6_11 , 30_6_2'? if it does, then you know is not an array...
Reply
#3

Seems like the following will do the trick. As Avenirer mentioned, it's most likely not an array.

$this->db->where_in('chat_session', explode(',', $latest_sessions))->update('chat_state', $update_state);
Reply
#4

Thanks both @SomeGuy and @Avenirer. Got the idea, in fact the parameter should be an array
The largest Bengali tutorial site on Web Development in this planet
Reply




Theme © iAndrew 2016 - Forum software by © MyBB