【发布时间】:2018-01-26 14:39:51
【问题描述】:
有人可以在 Laravel 中将此 php 代码转换为类似的东西吗?
$result = mysqli_query($conn, "SELECT birthday, count(*) FROM person group by birthday;");
while ($row = mysqli_fetch_array($result, MYSQL_NUM)) {
$yearvalues[$row[0]] = (int)$row[1];
}
像这样:
$female = Enroll::select(DB::raw("SUM(tot_enroll) as count"))
->orderBy(DB::raw('sy'))
->groupBy(DB::raw("(sy)"))
->where('gender','=', 'Female')
->get()->toArray();
$female = array_column($female, 'count');
【问题讨论】: