![]() |
[SOLVED] Problem with Where In? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLVED] Problem with Where In? (/showthread.php?tid=27354) |
[SOLVED] Problem with Where In? - El Forum - 02-08-2010 [eluser]daparky[/eluser] I've ran into a problem while developing an application. Basically what i'm trying to do is get a list of results, explode the id's into comma seperated and perform a where_in delete sql. My code: This piece of code is to delete a box as well as all the products within that box. Code: $this->db->select('stock_id'); When i print_r the $ids it shows them as 1,2,3 etc which is fine but when i print the last query out it shows the result as:- Code: WHERE stock_id IN ('1,2,3') Problem: It needs to have a quotation mark around all of the id numbers instead of around them as a whole. It should be doing this:- Code: WHERE stock_id IN ('1','2','3') This works if i do it in a normal query but i want to use active record. Any help is appreciated. p.s. this is what i did to solve the issue:- Code: $this->db->select('stock_id'); [SOLVED] Problem with Where In? - El Forum - 02-08-2010 [eluser]danmontgomery[/eluser] Code: $ids = implode(",", $product); Because you're imploding $ids before passing it to where_in, so you're passing it the string "1,2,3". Just remove the call to implode(). [SOLVED] Problem with Where In? - El Forum - 02-09-2010 [eluser]daparky[/eluser] [quote author="noctrum" date="1265681478"] Code: $ids = implode(",", $product); Because you're imploding $ids before passing it to where_in, so you're passing it the string "1,2,3". Just remove the call to implode().[/quote] Thank you, i've sorted it. I just used $product for the where_in. |