示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RssSources::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'source_id' => $this->source_id, 'active' => $this->active, 'is_full' => $this->is_full, 'is_combine' => $this->is_combine, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'category_id' => $this->category_id]);
     $query->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
示例#2
0
 public function actionIndex()
 {
     if ($rssSources = RssSources::findAll(["active" => "1"])) {
         foreach ($rssSources as $source) {
             Yii::$app->getDb()->close();
             $pid = pcntl_fork();
             Yii::$app->getDb()->open();
             if (!$pid) {
                 if ($source->is_full == 0) {
                     $detector = new RssNewsDetectorComponent($source);
                     $detector->run();
                 } else {
                     $parser = new RssNewsParserComponent($source);
                     $parser->run();
                 }
                 Yii::$app->end();
             }
         }
         while (pcntl_waitpid(0, $status) != -1) {
             $status = pcntl_wexitstatus($status);
             echo "Child {$status} completed\n";
         }
     }
 }
示例#3
0
 /**
  * Finds the RssSources model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  *
  * @return RssSources the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = RssSources::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }