Welcome Guest, Not a member yet? Register   Sign In
Complex SQL Query with Active Record
#2

[eluser]Aljebrini[/eluser]
i think you can user active record to do your query by writing full query then pass it to the db->get() function ...

$query = "SELECT category.id ,category.title , post.id , post.title , post.content ,COUNT(comments.id) as comment_count FROM categories as category , posts as post,comments Where post.status = 1 AND comments.status = 1 and post.category_id = category.id ";

$this->db->get($query) ;

i didn't test this query on your real database tables but it will work, try to see what you get from ..


Messages In This Thread
Complex SQL Query with Active Record - by El Forum - 12-18-2009, 04:48 AM
Complex SQL Query with Active Record - by El Forum - 12-18-2009, 05:27 AM
Complex SQL Query with Active Record - by El Forum - 12-18-2009, 05:27 AM
Complex SQL Query with Active Record - by El Forum - 12-18-2009, 06:46 AM
Complex SQL Query with Active Record - by El Forum - 12-18-2009, 09:19 AM
Complex SQL Query with Active Record - by El Forum - 12-18-2009, 09:48 AM
Complex SQL Query with Active Record - by El Forum - 01-01-2010, 09:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB