本文整理匯總了PHP中models\User::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::save方法的具體用法?PHP User::save怎麽用?PHP User::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionEdit_status
public function actionEdit_status()
{
$user = new User();
$user->find()->where(['id' => $_POST['userID']])->one();
$user->status = $_POST['status'];
$user->save();
}
示例2: actionSave_profile
public function actionSave_profile()
{
if (isset($_POST['saveProfile'])) {
$user = new User();
$usServ = new UserServices();
$vk_id = Cookie::get('vk_id');
$user->find()->where(['vk_id' => $vk_id])->one();
$usServ->deleteByField('user_id', $user->id);
$user->region_id = $_POST['region_id'];
$user->city_id = $_POST['city_id'];
$user->email = $_POST['email'];
$user->phone = $_POST['phone'];
$user->link = $_POST['link'];
$user->save();
foreach ($_POST['services'] as $serv) {
$usServ = new UserServices();
$usServ->user_id = $user->id;
$usServ->service_id = $serv;
$usServ->save();
}
header('Location: /vk2/office/my', true, 302);
} else {
Header::redirect('/vk2/profile/my', true, 302);
}
}
示例3: create
protected function create()
{
$params = arrayKeysSnakeToCamel($_POST['user']);
$user = new User();
$user->fromArray($params);
$user->save();
$this->addFlash("success", "registered");
redirectTo("/");
}
示例4: register
public static function register($email, $nick, $password)
{
$user = new User();
$user->email = $email;
$user->nick = $nick;
$user->password = password_hash($password, PASSWORD_DEFAULT);
$user->save();
return $_SESSION['user'] = $user->id;
}
示例5: actionCreate
public function actionCreate()
{
$user = new User();
$user->scenario = 'create';
if (isset($_POST['User']) && is_array($_POST['User']) && $user->load($_POST['User']) && $user->save()) {
$this->redirect(['site/index']);
}
$this->render('create', ['user' => $user]);
}
示例6: actionReg
public function actionReg()
{
$vk_id = $this->app->cookie->get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
$this->app->parser->render('profile', ['user' => $user]);
}
示例7: actionMy
public function actionMy()
{
$vk_id = Cookie::get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
$region = new GeobaseRegion();
$city = new GeobaseCity();
$regionAll = $region->find()->orderBy('name', 'ASC')->all();
$this->app->parser->render('profile', ['user' => $user, 'regionAll' => $regionAll]);
}
示例8: registerUser
function registerUser($postdata)
{
$regname = htmlentities($postdata['regname']);
$regpass = htmlentities($postdata['regpass']);
$regauth = htmlentities($postdata['regauth']);
$regpass = hash('sha256', $regpass);
$user = new User();
$user->setName($regname);
$user->setPassword($regpass);
$user->setAuthlevel($regauth);
$user->save();
}
示例9: actionReg
public function actionReg()
{
$vk_id = Cookie::get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
Header::redirect('/vk2/profile/my', true, 302);
/*$this->app->parser->render('profile',
[
'user' =>$user,
]);*/
}
示例10: create_new_account
/**
* Creates a New account
* @param Request object - which contains email, password etc
*
* @return Nothing
*/
public function create_new_account(Application $app, Request $request)
{
$email = $request->get('email');
$password = $app->escape($request->get('password'));
$confirm_password = $request->get('confirm_password');
$user = new User($app);
try {
$user->save('user', array('email' => $email, 'password' => md5($password), 'create_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")));
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
return $app->render('tweets.php.twig', array('error_message' => '', 'tweets' => []));
}
示例11: registerAction
public function registerAction()
{
$user = new User();
$success = $user->save($this->request->getPost());
if ($success) {
return $this->redirect('signin/index');
} else {
echo 'Sorry, the following problems were generated: ';
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), '<br/>';
}
}
$this->view->disable();
}
示例12: postRegister
public function postRegister(Request $request)
{
$validator = Validator::make($request->all(), ['login' => 'required|min:4|max:25|unique:user,login', 'pseudo' => 'required|min:4|max:25|unique:user,pseudo', 'password' => 'required|min:6|max:20|confirmed', 'email' => 'required|max:100|email|unique:user,email']);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator->errors())->withInput();
}
$u = new User();
$u->login = $request->input('login');
$u->pseudo = $request->input('pseudo');
$u->email = $request->input('email');
$u->password = Hash::make($request->input('password'));
$u->streaming = 0;
$u->save();
return redirect(route('getLogin'));
}
示例13: registerAction
public function registerAction()
{
if (F::$app->getRequest()->getIsPost()) {
$item = new User();
$item->username = $_POST['username'];
$item->password = $_POST['password'];
$item->repassword = $_POST['repassword'];
$item->date_created = time();
if ($item->save()) {
return "User was registered";
} else {
return "User was not registered";
}
}
return $this->render('register');
}
示例14: register
public function register()
{
if (isset($_POST['login'])) {
$this->redirect('users', 'login');
exit;
}
if (isset($_POST['register'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirm = $_POST['confirm'];
if ($username == null) {
echo 'Enter Valid Username!';
die;
}
if ($email == null) {
echo 'Enter email!';
die;
}
if ($password == null) {
echo 'Enter password!';
die;
}
if ($confirm == null) {
echo 'Confirm password!';
die;
}
if ($_POST['password'] != $_POST['confirm']) {
echo 'Confirm password and password are not the same!';
die;
}
$user = new User($username, $password, $email);
$user->save();
$userInstance = UserRepository::create()->getByName($username);
$newUserId = intval($userInstance['id']);
var_dump($userInstance);
if ($userInstance) {
CartRepository::create()->newCart($newUserId);
}
$this->redirect('users', 'login');
}
}
示例15: updateUser
/**
* Update the given user.
*
* @param Users $user
* The user to update
* @param array $data
* an array that contains the following fields :<pre>
* name
* email
* password
* </pre>
* @return boolean true if there is nothing to update or updating was done successfully, false otherwise.
*
*/
public static function updateUser(User $user, $data = array())
{
if (!$user instanceof User) {
return false;
}
$needsUpdate = false;
if (isset($data['name'])) {
$user->display_name = $data['display_name'];
$needsUpdate = true;
}
if (isset($data['password'])) {
$user->password = Hash::make($data['password']);
$needsUpdate = true;
}
if ($needsUpdate) {
return $user->save();
} else {
return true;
}
}