Active Record |
[eluser]schnoodles[/eluser]
Hello i was playing around with active record, and just got stuck with a select statement of Code: SELECT *,count(id),(SELECT MAX(id) FROM channelpollvote WHERE channelpollid=2) FROM channelpollvote WHERE channelpollid=2 GROUP BY vote; And i cannot think of how i could implement this :\ Does anyone know using the way of $this->db->select();
[eluser]phpwebdev[/eluser]
May be better to use another method $this->db->query('YOUR QUERY HERE'); http://ellislab.com/codeigniter/user-gui...eries.html Because this are too complex query (there have one sub query!). Check CI manual for active record (http://ellislab.com/codeigniter/user-gui...ecord.html), but i don't thinks this is passable ! PS. Sorry ,but English not my natural language
[eluser]schnoodles[/eluser]
Yes i know i can do a query like that, but the reason i didnt want to is, because in the future i may change databases from mysql to say pgsql and that may not support that exact query syntax.
[eluser]Michael Wales[/eluser]
I don't think CI's current implementation of Active Record can support that query. As the previous posted said, it's quite complex. Active Record is great for the simple, every day, queries - but when you get into things like this - it's not always the best choice (or even a possible choice). |
Welcome Guest, Not a member yet? Register Sign In |