コード例 #1
0
 public function actionDetails($id)
 {
     //        $test = Posts::getTest();
     $query = Posts::findOne($id);
     $post = Posts::find()->where(['id' => $id])->one();
     return $this->render('details', ['post' => $post, 'query' => $query]);
 }
コード例 #2
0
 public function actionOrders($category)
 {
     $query = Job::find()->where(['category_id' => $category]);
     $query2 = Posts::find()->where(['category_id' => $category]);
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $orders = $query->orderBy('create_date DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     $postOrders = $query2->orderBy('create_date DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('orders', ['orders' => $orders, 'pagination' => $pagination, 'postOrders' => $postOrders]);
 }
コード例 #3
0
ファイル: PostSearch.php プロジェクト: dalinhuang/wethepeople
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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, 'author' => $this->author, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: PostSearch.php プロジェクト: sydorenkovd/yiiadv
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'create_date' => $this->create_date, 'author_id' => $this->author_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'is_moderate', $this->is_moderate])->andFilterWhere(['like', 'author.name', $this->getAttribute('author.name')]);
     return $dataProvider;
 }
コード例 #5
0
ファイル: PostsSearch.php プロジェクト: ray0916/yii2-learn
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['post_id' => $this->post_id, 'author_id' => $this->author_id]);
     $query->andFilterWhere(['like', 'post_title', $this->post_title])->andFilterWhere(['like', 'post_description', $this->post_description]);
     return $dataProvider;
 }
コード例 #6
0
ファイル: PostsSearch.php プロジェクト: bokko79/servicemapp
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'post_category_id' => $this->post_category_id, 'status' => $this->status, 'published' => $this->published, 'time' => $this->time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'subtitle', $this->subtitle])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
コード例 #7
0
 public function actionDetails($id)
 {
     $post = Posts::find()->where(['id' => $id])->one();
     return $this->render('details', ['post' => $post]);
 }
コード例 #8
0
 public function actionPost()
 {
     $provider = new ActiveDataProvider(['query' => Posts::find()->orderBy('created_at DESC'), 'pagination' => ['pageSize' => 20]]);
     return $this->render('post', ['dataProvider' => $provider]);
 }
コード例 #9
0
ファイル: Posts.php プロジェクト: sydorenkovd/yiiadv
 public function getPublishedPosts()
 {
     return new ActiveDataProvider(['query' => Posts::find()->where(['is_moderate' => self::IS_MODERATE])->orderBy(['create_date' => SORT_DESC])]);
 }