我喜欢将以下MySQL查询转换为Codeigniter Active Record Queries.
以下是MySQL:
select brand_id,name,(select count(*) from items where brand_id = b.brand_id) as itemc, (select count(*) from models where brand_id = b.brand_id) as modelc from brands as b
Run Code Online (Sandbox Code Playgroud)
Codeigniter:
$this->db->limit($perpage,$page);
$query = 'select brand_id,name,(select count(*) from items where brand_id = b.brand_id) as itemc, (select count(*) from models where brand_id = b.brand_id) as modelc from brands as b limit '.$perpage.' offset '.$page.'';
$query = $this->db->query($query);
$query = $query->result();
return $query;
Run Code Online (Sandbox Code Playgroud)
请帮我将以上代码转换为Codeigniter Active Record.