I need a bit of help converting this SQL to CI Active Record format |
[eluser]solconnection[/eluser]
Hi there, being new to CI i was hoping some kind soul could point me in the right direction in converting the below SQL query to the format CI uses. Alternatively, is there an easy way to use pure SQL queries?, it would be nice to keep the code database agnostic, but in all likelihood it's going to be running on an SQL in most (all?) cases. Code: select root.name as root_name i am trying to implement a subcategories system using the theory on this page http://sqllessons.com/categories.html if there is a good solution existing then id be happy just to learn from that too thanks in advance for any advice have a nice day -D
[eluser]WanWizard[/eluser]
Something like Code: $this->db->select('root.name AS root_name, down1.name AS down1_name, down2.name AS down2_name, down3.name AS down3_name');
[eluser]solconnection[/eluser]
[quote author="WanWizard" date="1282603974"]Something like .... [/quote] struth, that was quick!!! thank you very much, ill see how it goes, appreciate the help! -D
[eluser]mddd[/eluser]
You can easily just use pure sql if you want: Code: $query = $this->db->query('select * from my_table where id=1');
[eluser]solconnection[/eluser]
[quote author="mddd" date="1282604130"]You can easily just use pure sql if you want: ...[/quote] another really fast and helpful reply is this the best forum ever? thanks mddd, much appreciated -D
[eluser]Jondolar[/eluser]
You may want to look at nested sets or materialized paths as an alternative approach to managing subcategories. Good luck with your project.
[eluser]solconnection[/eluser]
Thanks Jondolar, i shall indeed check into these approaches -D |
Welcome Guest, Not a member yet? Register Sign In |