CodeIgniter Forums
Active Record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Active Record (/thread-2714.html)



Active Record - El Forum - 08-20-2007

[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();


Active Record - El Forum - 08-21-2007

[eluser]phpwebdev[/eluser]
May be better to use another method
$this->db->query('YOUR QUERY HERE');
http://ellislab.com/codeigniter/user-guide/database/queries.html
Because this are too complex query (there have one sub query!).

Check CI manual for active record (http://ellislab.com/codeigniter/user-guide/database/active_record.html), but i don't thinks this is passable !

PS. Sorry ,but English not my natural language


Active Record - El Forum - 08-21-2007

[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.


Active Record - El Forum - 08-21-2007

[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).