public function getUser() { if ($this->_user === false) { $this->_user = User::find()->where(['phone' => $this->phone, 'pwd' => md5($this->pwd)])->one(); } return $this->_user; }
public function actionGet() { $data = Yii::$app->request->post(); $user = new User(); $phone = $user->find()->select('id')->where(['phone' => $data['phone']])->one(); $aa = (new \yii\db\Query())->select('a.*')->from('usertoapp u')->join('LEFT JOIN', 'app a', 'a.id=u.appid')->where('a.version >\'\' and u.userid=:id', ['id' => $phone['id']])->all(); return $aa; }
public function actionZan() { $data = Yii::$app->request->post(); $user = new User(); $phone = $user->find()->select('id')->where(['phone' => $data['phone']])->one(); $info = User::findOne(['phone' => $data['phone']]); if ($info) { $info->favour += 1; $info->save(); echo json_encode(array('flag' => 1, 'msg' => 'favour success.')); } else { echo json_encode(array('flag' => 0, 'msg' => 'favour fail.')); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); $query->andFilterWhere(['famous' => 0]); 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, 'famous' => $this->famous, 'shared' => $this->shared, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'pwd', $this->pwd])->andFilterWhere(['like', 'authKey', $this->authKey])->andFilterWhere(['like', 'nickname', $this->nickname])->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'area', $this->area])->andFilterWhere(['like', 'job', $this->job])->andFilterWhere(['like', 'hobby', $this->hobby])->andFilterWhere(['like', 'signature', $this->signature]); return $dataProvider; }
public function actionLike() { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $data = Yii::$app->request->post(); $model = new User(); $myid = $model->find()->select('id')->where(['phone' => $data['phone']])->one(); $aa = (new \yii\db\Query())->select('a.*')->from('friends f')->join('INNER JOIN', 'usertoapp ua', 'f.friendid=ua.userid and f.friendid <> f.myid and f.myid=:id', ['id' => $myid['id']])->join('INNER JOIN', 'app a', 'ua.appid=a.id')->all(); return $aa; }
public function actionReply() { $data = Yii::$app->request->post(); $user = new User(); $fromphone = $user->find()->select('id')->where(['phone' => $data['fphone']])->one(); $model = new Reply(); if ($data['tphone'] == '') { $model->toid = 0; } else { $tophone = $user->find()->select('id')->where(['phone' => $data['tphone']])->one(); $model->toid = $tophone['id']; } $to = Message::findOne(['id' => $data['msgid']]); if ($fromphone['id'] != $to['id']) { $model3 = new Notify(); $model3->from = $fromphone['id']; $model3->to = $to['userid']; $model3->message = '评论'; $model3->created_at = time(); if (!$model3->save()) { echo json_encode(array('flag' => 0, 'msg' => 'Reply failed!')); return; } } $model->fromid = $fromphone['id']; $model->msgid = $data['msgid']; $model->content = $data['content']; $model->isread = 0; $model->created_at = time(); if ($model->save()) { echo json_encode(array('flag' => 1, 'msg' => 'Reply success!')); } else { echo json_encode(array('flag' => 0, 'msg' => 'Reply failed!')); } }
/** * Lists all User models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => User::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public function actionSearchStar() { $data = Yii::$app->request->post(); Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model = new User(); $ans = $model->find()->select('*')->from('user')->where('famous=1')->andWhere(['like', 'nickname', $data['name']])->all(); return $ans; }