public function search($params) { $query = MItem::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'cid'); $this->addCondition($query, 'title', true); return $dataProvider; }
/** * Finds the MItem model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return MItem the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MItem::find($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<a data-ajax=false href="http://m.10010.com/mobilegoodsdetail/711408014789.html?src=wolm&channel=cps&cid=8a94a89148bf746b0148bfe4ee5600ef&adid=8a94a891487978800148826b0d5a005a"> 华为荣耀6 </a> </li> <!-- <li> <a data-ajax=false href=""> 小米红米1S </a> </li> --> <?php //$models = MItem::findAll(['kind'=>MItem::ITEM_KIND_MOBILE]); $models = MItem::find()->where(['kind' => MItem::ITEM_KIND_MOBILE])->orderBy(['price' => SORT_DESC])->all(); ?> <?php foreach ($models as $model) { ?> <li><a data-ajax=false href="<?php echo Url::to(['mobile', 'cid' => $model->cid, 'gh_id' => $gh_id, 'openid' => $openid]); ?> "> <?php echo $model->title; ?> </a></li> <?php } ?>
public function actionLlb() { $this->layout = 'wapy'; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $kind = $_GET['kind']; $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if (empty($user->openidBindMobiles)) { Yii::$app->getSession()->set('RETURN_URL', Url::to()); return $this->redirect(['addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid]); } $cats = $this->getLLBCatsByMobiles($user->getBindMobileNumbers()); if (empty($cats)) { return $this->render('lyhzxyhhint', ['gh_id' => $gh_id, 'openid' => $openid]); } //$models = MItem::find()->where(['kind'=>$kind, 'cid'=>$cats])->orderBy(['price'=>SORT_ASC])->all(); $models = MItem::find()->where(['kind' => $kind])->orderBy(['price' => SORT_ASC])->all(); U::W("\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$"); U::W($models); U::W($cats); return $this->render('llb', ['gh_id' => $gh_id, 'openid' => $openid, 'user' => $user, 'models' => $models, 'kind' => $kind]); }