CI pass array to model where clause |
Anyone can help me with this problem here? http://stackoverflow.com/questions/34704...ere-clause
Basically, I want it to look like this: UPDATE table SET active = 0 WHERE row_id = 1 OR row_id = 2 OR row_id = 3... Where in the row_id are from the array in controller.
$this->db->where_in( 'row_id', array('1','2','3') );
(01-10-2016, 09:25 PM)skunkbad Wrote: $this->db->where_in( 'row_id', array('1','2','3') ); Hello dear, I am stuck in a condition. I have array of keywords like array('business','permanent') now can you please tell me how to pass this array into where clause because where_in is only valid for ids(integers) and when i am using the below statement it through error $this->db->where('Keyword',array('business','permanent')) ; or $this->db->or_where('Keyword',array('business','permanent')) ; or $this->db->or_where(array('business','permanent')) ; Please help Thank you.
Try this and see if it is what you want.
PHP Code: $where = "Keyword = 'business' OR Keyword = 'permanent'"; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Are you absolutely sure the table field is "Keyword" (with capital K)? MySQL is case-sensitive regarding field names.
|
Welcome Guest, Not a member yet? Register Sign In |