コード例 #1
0
ファイル: KpiResultController.php プロジェクト: cmbis/cmbis
 public function actionScorechangwat()
 {
     $query = CmbisKpiResultHcode::find()->groupBy(['hcode'])->orderBy('avg(kpi_score) DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 25]]);
     $dataProvider->setSort(['attributes' => ['avgScore' => ['asc' => ['avg(kpi_score)' => SORT_ASC], 'desc' => ['avg(kpi_score)' => SORT_DESC], 'default' => SORT_ASC, 'label' => 'avg_score']]]);
     return $this->render('scorechangwat', ['dataProvider' => $dataProvider]);
 }
コード例 #2
0
ファイル: CmbisKpiResultHcode.php プロジェクト: cmbis/cmbis
 public function getAvgScore()
 {
     return $this->hasMany(CmbisKpiResultHcode::className(), ['hcode' => 'hcode'])->average('kpi_score');
 }