public function actionLogin() { $user_name = \Yii::$app->request->post()['user_name']; $password = \Yii::$app->request->post()['pwd']; $author_info = new Author(); $author_info->name = $user_name; $author_info->pwd = $password; if ($author_info->save()) { $author_id = Author::findBySql("select id from author ORDER BY id DESC LIMIT 0,1")->asArray()->all(); $array = ['error_no' => 0, 'error_msg' => '', 'data' => $author_id[0]]; echo json_encode($array); } }