Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
$data = array();
foreach ( ORM::factory('Role')->find_all() as $role) {
$data[$role->name] = $role->users->count_all();
}
arsort($data);
echo Debug::vars($data);
$data = DB::select(DB::expr('count(user_id) cnt, roles.name'))
->distinct(TRUE)
->from('roles_users')
->join('roles', 'RIGHT')
->on('roles_users.role_id', '=', 'roles.id')
->group_by('role_id')
->order_by('cnt', 'DESC')
->execute();
echo Debug::vars($data->as_array());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question