Write a query with Active Record Class |
[eluser]bestmomo[/eluser]
Hello Is there a way to write this query with pure Active Record Class : Code: return $this->db->query("SELECT * FROM content WHERE `sectionid` != 'com_weblinks' Thanks
[eluser]apodner[/eluser]
This is about as close as I can get. Maybe someone else can get you closer, but I am not sure that you can use Active Record to nest the where clause like you have done here. Not having your db table, I cannot guarantee this will work, but hopefully it will get you on the right track. Code: $arrSectionNot = array('com_weblinks', 'com_bibliographie', 'com_events', 8);
[eluser]bestmomo[/eluser]
Thank you for your answer, it works. I think there is no simple way to get the WHERE with the LIKE items with Active Record Class, unless by writing an extension to DB_active_rec.php.
[eluser]CroNiX[/eluser]
[quote author="bestmomo" date="1355585672"]Thank you for your answer, it works. I think there is no simple way to get the WHERE with the LIKE items with Active Record Class, unless by writing an extension to DB_active_rec.php. [/quote] The next version of CI, available on GitHub (not complete) has methods for doing what you are wanting. See the "Query Grouping" section here.
[eluser]bestmomo[/eluser]
Thanks for this answer. I looked at next version which has effectively grouping queries with parantheses. I keep my half solution for now. I'll upgrade it when V3 will be stable ![]()
[eluser]apodner[/eluser]
This is the second time this type of question has been posted in the last week or so. I have also worked around it in the past. I believe it can be accomplished by extending the Active Record class (without modding the system core). https://github.com/AndrewPodner/ci_ar_where_paren Try the above, it should get the job done |
Welcome Guest, Not a member yet? Register Sign In |