示例#1
0
 /**
  * Lists all Sensor models.
  * @return mixed
  */
 public function actionIndex()
 {
     $query = Sensor::find()->orderBy('active DESC, binary_pos ASC');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#2
0
 public function initSensor($stationId)
 {
     if ($stationId > 0) {
         $sensors = Sensor::find()->all();
         if (!empty($sensors)) {
             foreach ($sensors as $sensor) {
                 $data[] = [$sensor->id, $stationId];
             }
             Yii::$app->db->createCommand()->batchInsert('sensor_status', ['sensor_id', 'station_id'], $data)->execute();
         }
     }
 }