本文整理汇总了PHP中UserService::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::save方法的具体用法?PHP UserService::save怎么用?PHP UserService::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register()
{
$this->validate(array('name' => 'required,min(2)', 'email' => 'required,email', 'password' => 'required,min(4)', 'password2' => 'required,min(4),equal(password)'));
$userDoc = Request::post()->get('name', 'email', 'password');
$userDoc->password = md5($userDoc->password);
$userDoc = UserService::save($userDoc);
if (!$userDoc) {
MessageHandler::instance()->addError('E-mail was already registered - forgot your password?');
return;
}
$user = new UserModel($userDoc);
SessionHandler::instance()->setUser($user);
MessageHandler::instance()->addMessage('You were successfully registered and logged in');
$this->redirect();
}
示例2: actionUpdate
public function actionUpdate()
{
$model = UserService::loadModel();
$this->performAjaxValidation($model);
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
if (UserService::save($model)) {
Flashes::addInfoFlash(Yii::t('amo', 'User updated successfully'));
$this->redirect(array('view', 'id' => $model->uid));
} else {
Flashes::addErrorFlash(Yii::t('amo', 'Could not update the user.') . ' ' . Yii::t('amo', 'Please, try again later.'));
}
}
$this->render('update', array('model' => $model));
}
示例3: editAction
public function editAction($id)
{
$this->response->setTemplate('user-edit');
$user_service = new UserService();
$this->response->view->success = "";
$this->response->view->error = "";
if ($this->response->getPost() && $user_service->save($this->response->getPost())) {
#salvo com sucesso
$this->response->view->success = "Funcionario salvo com sucesso.";
$this->indexAction();
} elseif ($this->response->getPost()) {
/**
* Mostrar o motivo do porque nao foi salvo
*/
$this->response->view->error = "Precisa preencher todos os campos obrigatorios!!!";
}
$user = $user_service->get($id);
$this->response->view->user = $user;
}
示例4: User
<?php
require __DIR__ . "/../autoload.php";
$user = new User();
$user->setName("Zachary");
$userService = new UserService();
$userService->save($user);