/** * @return string 读取用户列表 */ public function actionIndex() { $model = new YiiUser(); $where = []; if (YII::$app->request->get('user')) { $where = ['like', 'user', YII::$app->request->get('user')]; } $count = $model->find()->where(['role_id' => 0])->andwhere($where)->count(); $page = new Pagination(['defaultPageSize' => 10, 'totalCount' => $count]); $list = $model->find()->where(['role_id' => 0])->andwhere($where)->orderBy('id desc')->offset($page->offset)->limit($page->limit)->all(); return $this->render('index', ['users' => $list, 'page' => $page, 'user' => YII::$app->request->get('user', '')]); }
/** * @return string|\yii\web\Response 用户注册 */ public function actionSignup() { $model = new YiiUser(); $data = Yii::$app->request->post(); //$model->user=$data['user']; $model->pwd = md5($data['pwd']); //$model->authKey=$data['authKey']; //$model->accessKey=$data['accessKey']; $model->email = $data['email']; //$model->find()->where(['email'=>$data['email']])->one(); if ($model->find()->where(['email' => $data['email']])->one() || $model->find()->where(['user' => $data['user']])->one()) { echo "already exists"; } else { $model->save(); echo json_encode("sighup success"); } }
public function createCompanyNum() { $num = YiiUser::find()->max('cnum'); return intval($num) + 1; }