Need help with Active Record: using where_in and like and or_like at the same time does not work... - 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: Need help with Active Record: using where_in and like and or_like at the same time does not work... (/showthread.php?tid=45978) |
Need help with Active Record: using where_in and like and or_like at the same time does not work... - El Forum - 10-13-2011 [eluser]Unknown[/eluser] Need help with Active Record: using where_in and like and or_like at the same time does not work out... Here is my code : Code: // Making sure categories are visible and this is the get_all_visible_cats() method (which works very well in other instances where I'm using where_in but not like and or_like at the same time) Code: function get_all_visible_cats() Here is the SQL query that it generates: Code: SELECT * FROM (`videos`) WHERE `category` IN ('6', '7', '8', '9', '11', '12', '13') AND `video_name` LIKE '%test%' OR `username` LIKE '%test%' OR `description` LIKE '%test%' OR `tags` LIKE '%test%' In another method that I have, I use it like this and it works perfectly: Code: // Making sure categories are visible Any help is appreciated! Thank you. EDIT: I forgot to mention what doesn't work. The like() and or_like() functions work well, I get the search results correctly. What doesn't work is the where_in.. It gives me all categories including the ones that are not even in the array (see SQL query up here).. The last bit of code that I posted does not return these non-visible categories.. That is the goal. |