where(['role' => 0])->count(); if ($count===0) { $model = new Admin(); $model->username = StringHelper::random(6); $model->generateAuthKey(); $password_hash = StringHelper::random(10); $model->setPassword($password_hash); if ($model->save()) { Console::output('username; ' . $model->username); Console::output('password; ' . $password_hash); exit(); } Console::stdout('Password initialization failed'); exit(); } Console::stdout('已经有超管账号'); exit(); } }