public function actionListenadd() { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model1 = new Reqfriend(); $model = new User(); $data = Yii::$app->request->post(); $myid = $model->find()->select('id')->where(['phone' => $data['phone']])->one(); //$fid = $model->find()->select('id')->where(['phone'=>$data['fphone']])->one(); $num = $model1->find()->andWhere(['friendid' => $myid['id']])->count(); if ($num > 0) { $aa = (new \yii\db\Query())->select('phone,thumb,nickname')->from('reqfriend f')->join('LEFT JOIN', 'user u', 'f.myid=u.id')->where(['f.friendid' => $myid['id']])->all(); return $aa; } else { echo json_encode(array('flag' => 0, 'msg' => 'Have no req')); } }