изменить этот запрос $query = $this->db->query->
на $query = $this->db->query("your sql query")
public function get_by_role()
{
$query = $this->db->query->("SELECT b. * FROM (SELECT a. *, @rank := @rank + 1 rank FROM (SELECT MAX(score) AS max_score, user_id FROM highscore WHERE game_mode="bungkata" GROUP BY user_id ORDER BY max_score DESC)a, (SELECT @rank := 0)r)b LIMIT 10");
return $query->result();
}