public function actionNotify() { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $data = Yii::$app->request->post(); $phone = User::findOne(['phone' => $data['phone']]); if (!$phone) { echo json_encode(array('flag' => 0, 'msg' => 'Phone does not exist!')); return; } $ans = (new \yii\db\Query())->select('nickname,phone,thumb,message')->from('notify n')->join('INNER JOIN', 'user u', 'u.id=n.from and n.to=:id', [':id' => $phone['id']])->all(); $dels = Notify::findAll(['to' => $phone['id']]); foreach ($dels as $del) { $del->delete(); } return $ans; }