Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord Return Row id
#7

[eluser]chrislorenz[/eluser]
Yeah, I realized that once I started piecing everything together. I worked around it by doing this:
Code:
function get_submissions_rank()
        {

            $resetrank = 'SET @rank := 0';
            $this->db->query($resetrank);
            $query = 'SELECT rank, VoteCount, submission_id FROM (
                        SELECT @rank:=@rank+1 AS rank, s.submission_id
                              , Count( v.submission_id ) AS VoteCount
                        FROM submission AS s
                        LEFT JOIN vote AS v
                              ON v.submission_id = s.submission_id
                        WHERE 1=1
                        GROUP BY s.submission_id
                        ORDER BY rank ASC
                        ) AS t';
            $result = $this->db->query($query);
}

This seems to work but after going through all of this I think I may just end up iterating with a counter.


Messages In This Thread
ActiveRecord Return Row id - by El Forum - 05-10-2010, 05:30 PM
ActiveRecord Return Row id - by El Forum - 05-11-2010, 08:08 AM
ActiveRecord Return Row id - by El Forum - 05-12-2010, 10:01 AM
ActiveRecord Return Row id - by El Forum - 05-12-2010, 05:21 PM
ActiveRecord Return Row id - by El Forum - 05-13-2010, 03:21 PM
ActiveRecord Return Row id - by El Forum - 05-13-2010, 03:38 PM
ActiveRecord Return Row id - by El Forum - 05-13-2010, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB