Exemplo n.º 1
0
 public static function getTeachersCountGroupByArea()
 {
     $result = Yii::$app->db->createCommand('SELECT count(t.id) as count,train.district FROM  ' . self::tableName() . ' t LEFT JOIN ' . TrainTeachers::tableName() . ' tt ON t.id = tt.teachers_id LEFT JOIN ' . Train::tableName() . ' train ON tt.train_id = train.id WHERE train.district is not null group by train.district')->queryAll();
     return $result;
 }