这是我的代码!我如何得到只有两位小数的平均值?
public function getAveRating($restoid){
$where=array(
"restoid"=>$restoid
);
$this->db->where($where);
$this->db->select_avg('rate');
$query = $this->db->get('ratings')->first_row('array');
return $query['rate'];
}如何在获得评级时将平均值限制在小数点后2位?
发布于 2016-03-05 00:42:45
public function getAveRating($restoid){
$where=array(
"restoid"=>$restoid
);
$this->db->where($where);
$this->db->select_avg('rate');
$query = $this->db->get('ratings')->first_row('array');
return round($query['rate'], 2);
}发布于 2016-03-05 00:43:07
将return $query['rate'];更改为return round($query['rate'],2);
https://stackoverflow.com/questions/35801346
复制相似问题