function get_user($start = 0, $limit = 5) {
$sql = "SELECT u.articles as num, u.id,u.name FROM `user` as u LIMIT $start,$limit";
$list = array ();
$query = $this->db->query ( $sql );
foreach ( $query->result_array () as $model ) {
$followed = $this->followed ( $model ['id'], $this->base->user ['id'] );
$model ['hasfollower'] = $is_followed == 0 ? "0" : "1";
$list [] = $model;
}
return $list;
}
现在需要基于上面的数组中的id作为条件,来再次查询
select sum(views) from topic where author=$model ['id']
那么我需要在数组每个值中输出sum(views)。
应该怎么结合。