$result = DB::select(DB::expr('*'), DB::expr('COUNT(*) as count'))->from('votes')->group_by('suggestion_id')->order_by('count', 'desc')->limit(10)->as_object('Model_Votes')->execute();
if ($result)
{
foreach ($result as $vote)
{
// access the suggestion from the result vote record
echo $vote->suggestion->name;
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!