当前位置: 首页>>代码示例>>PHP>>正文


PHP UserModel::save方法代码示例

本文整理汇总了PHP中UserModel::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::save方法的具体用法?PHP UserModel::save怎么用?PHP UserModel::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 function create($name)
 {
     $this->user->setName($name);
     $this->user->set('role', 'user');
     $this->user->set('email', $name . '@service.com');
     $this->user->save();
     return true;
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:8,代码来源:UserService.php

示例2: actionRegister

 public function actionRegister()
 {
     $connection = Yii::app()->db;
     $email = $_REQUEST['email'];
     $password = $_REQUEST['pwd'];
     $ret = UserModel::model()->find('email=:email', array(':email' => $email));
     if (isset($ret)) {
         //email 已经注册
         echo json_encode(array('result' => 2, 'comment' => 'Email had been  registed'));
         return;
     }
     $userModel = new UserModel();
     $userModel->username = 'please set your nickname';
     $userModel->password = $password;
     $userModel->password2 = $password;
     $userModel->email = $email;
     $userModel->create_time = time();
     if ($userModel->save()) {
         //找到名字对应的_id。
         $sql = "select _id from tbl_user where email = :email";
         $command = $connection->createCommand($sql);
         $tmp = $command->query(array(':email' => $email))->readAll();
         echo json_encode(array('result' => 1, 'res' => $tmp[0]["_id"]));
     } else {
         echo json_encode(array('result' => 0));
     }
 }
开发者ID:dalinhuang,项目名称:styleshop,代码行数:27,代码来源:ApiController.php

示例3: add

 function add($user_id, $cause)
 {
     if (strlen(trim($cause))) {
         $userModel = new UserModel();
         $currentUser = Project::getUser()->getDbUser();
         $userModel->load($user_id);
         if ($userModel->id) {
             $banHistoryModel = new BanHistoryModel();
             $paramModel = new ParamModel();
             $n_warnings_to_ban = $paramModel->getParam("UserController", "N_WARNINGS_TO_BAN");
             $t_ban_time_sec = $paramModel->getParam("UserController", "T_BAN_TIME_SEC");
             $count_user_warnings = $this->getUserWarningCount($user_id);
             $this->clear();
             $this->user_id = (int) $user_id;
             $this->cause = $cause;
             $warning_id = $this->save();
             if ($userModel->warnings_fromlast_ban + 1 >= $n_warnings_to_ban) {
                 // пора банить
                 $subject = "Ваш аккаун заблокирован в системе Next24.ru";
                 $userModel->warnings_fromlast_ban = 0;
                 $userModel->banned = 1;
                 $userModel->banned_date = time();
                 $banHistoryModel->ban($user_id, $currentUser->id, $warning_id, date("Y-m-d H:i:s", time() + $t_ban_time_sec));
             } else {
                 $userModel->warnings_fromlast_ban = $userModel->warnings_fromlast_ban + 1;
                 $subject = "Администратор Next24.ru установил Вам предупреждение";
             }
             $userModel->save();
             $url_referer = $_SERVER['HTTP_REFERER'];
             $this->sendMessage((int) $user_id, $subject, $cause, $url_referer);
             return $warning_id;
         }
     }
     return 0;
 }
开发者ID:amanai,项目名称:next24,代码行数:35,代码来源:WarningModel.php

示例4: execute

 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectContao($output, true);
     if ($this->initContao()) {
         // Username
         if (($username = $input->getArgument('username')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $username = $dialog->ask($output, '<question>Username:</question>');
         }
         // Email
         if (($email = $input->getArgument('email')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $email = $dialog->ask($output, '<question>Email:</question>');
         }
         // Password
         if (($password = $input->getArgument('password')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $password = $dialog->ask($output, '<question>Password:</question>');
         }
         // Name
         if (($name = $input->getArgument('name')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $name = $dialog->ask($output, '<question>Name:</question>');
         }
         // create new user
         $user = new \UserModel();
         $user->setRow(array('username' => $username, 'name' => $name, 'email' => $email, 'password' => \Encryption::hash($password), 'admin' => 1))->save();
         $user->save();
         $output->writeln('<info>User <comment>' . $username . '</comment> successfully created</info>');
     }
 }
开发者ID:iMi-digital,项目名称:imi-conrun,代码行数:36,代码来源:CreateUserCommand.php

示例5: actionInsert

 public function actionInsert()
 {
     if (isset($_POST['submit']) && $_POST['submit'] == 'Insert Procuct') {
         $pro = new ProModel();
         $pro->name = $_POST['product_name'];
         $pro->description = $_POST['product_desc'];
         $product_image = $_FILES['product_image']['name'];
         $product_image_tmp = $_FILES['product_image']['tmp_name'];
         move_uploaded_file($product_image_tmp, "img/{$product_image}");
         $pro->image = $product_image;
         $pro->price = $_POST['product_price'];
         $pro->save();
         header('Location: http://localhost/task/task2/admin_area/index.php');
         exit;
     }
     if (isset($_POST['sub'])) {
         $user = new UserModel();
         $user->first_name = $_POST['fn'];
         $user->last_name = $_POST['ln'];
         $user->email = $_POST['em'];
         $user->save();
         $ord = new OrdersModel();
         $ord->user_id = $_POST['id'];
         $ord->sum = $_POST['price'];
         $ord->order_date = date("Y/m/d h:i:s");
         $ord->save();
         $ordPro = new OrdersProModel();
         $ordPro->order_id = $_POST['id'];
         $ordPro->product_id = $_POST['id'];
         $ordPro->qty = $_POST['quantity'];
         $ordPro->save();
         header('Location: http://localhost/task/task2/admin_area/index.php');
         exit;
     }
 }
开发者ID:goginyan,项目名称:tutorial,代码行数:35,代码来源:ControllerPro.php

示例6: signup

 /**
  * Display listing of the resource
  *
  * @return Response
  */
 public function signup()
 {
     // obtin data curenta
     $today = date("Y-m-d H:i:s");
     $userdata = array('givenname' => Input::get('givenname'), 'surname' => Input::get('surname'), 'username' => Input::get('username'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'));
     //set validation rules
     $rules = array('givenname' => 'alpha_num|max:50', 'surname' => 'alpha_num|max:50', 'username' => 'required|unique:users,username|alpha_dash|min:5', 'email' => 'required|unique:users,email|email');
     //run validation check
     $validator = Validator::make($userdata, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $user = new UserModel();
         $user->givenname = Input::get('givenname');
         $user->surname = Input::get('surname');
         $user->username = Input::get('username');
         $user->email = Input::get('email');
         $user->photo = 'No photo found';
         $user->password = Hash::make(Input::get('password'));
         $user->active = "1";
         $user->isdel = "0";
         $user->last_login = $today;
         $user->access = "User";
         $user->save();
     }
     //else if
     return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('User account created', 'success'));
 }
开发者ID:dannyneamtu,项目名称:lara_project1,代码行数:33,代码来源:UserController.php

示例7: user_model_test

function user_model_test($delete)
{
    $user = new UserModel("Not", "Here", "not.here@nowhere.com", "password", date("Y-m-d H:i:s"));
    $user->save();
    $user->print_fields();
    $user->set("failed_login_attempts", 3);
    $user->set("first_name", "User");
    $user->set("last_name", "McUsage");
    $user->save();
    $user->print_fields();
    if ($delete) {
        $user->delete();
    }
    $um = UserModel::find(UserModel::first()->id);
    $um->print_fields();
    $um = UserModel::find(UserModel::last()->id);
    $um->print_fields();
    UserModel::find(999);
}
开发者ID:spencerbartz,项目名称:horrie_international,代码行数:19,代码来源:user_model.php

示例8: createUserModelByUser

 public function createUserModelByUser($user)
 {
     $treeObject = $this->getTree();
     $tree = $treeObject->fetchTree();
     foreach ($tree as $node) {
         $um = new UserModel();
         $um->DomainModel = $node;
         $um->User = $user;
         $um->save();
     }
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:11,代码来源:DomainModelTable.class.php

示例9: save

 public function save($acl = false)
 {
     $this->removeProperties('actags');
     if (parent::save()) {
         if ($acl) {
             $this->saveACL($acl);
         }
         return true;
     }
     return false;
 }
开发者ID:jaeko44,项目名称:time-tracking,代码行数:11,代码来源:user_acl.php

示例10: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new UserModel();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['user'])) {
         $model->attributes = $_POST['user'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:dalinhuang,项目名称:styleshop,代码行数:17,代码来源:UserController.php

示例11: processForm

function processForm()
{
    $errors = [];
    $errors['count'] = 0;
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $firstName = Input::getString('first_name');
        } catch (Exception $e) {
            $errors['first_name'] = 'First Name: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $lastName = Input::getString('last_name');
        } catch (Exception $e) {
            $errors['last_name'] = 'Last Name: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $email = Input::getString('email');
        } catch (Exception $e) {
            $errors['email'] = 'Email Address: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            if ($_POST['password1'] != $_POST['password2']) {
                throw new UnexpectedValueException("Do Not Match!");
            }
            $passwordOneHashed = Input::getPassword('password1', $firstName, $lastName, $email);
        } catch (Exception $e) {
            $errors['password1'] = 'Password: ' . $e->getMessage();
            $errors['count']++;
        }
        if ($errors['count'] == 0) {
            //no errors - add to the database
            $userObject = new UserModel();
            $userObject->first_name = $firstName;
            $userObject->last_name = $lastName;
            $userObject->email = $email;
            $userObject->password = $passwordOneHashed;
            $userObject->save();
            header("Location: /users.show.php?id=" . $userObject->id);
            //this will be the $_GET for the users.show.php
            die;
        }
    }
    return $errors;
}
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:48,代码来源:users.create.php

示例12: actionForget

 public function actionForget()
 {
     $model = new UserForm('foget');
     $msg = '';
     if (!empty($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate()) {
             $user = new UserModel();
             $user->password = UserModel::model()->cryptPass($pass = UserModel::model()->genPassword());
             $user->save();
             Yii::app()->email->send($model->email, 'Новый пароль', 'Ваш новый пароль:' . $pass);
             $msg = 'Новый пароль отправлен Вам на почту.';
         }
     }
     $this->render('forget', ['model' => $model, 'msg' => $msg]);
 }
开发者ID:Alamast,项目名称:pravoved,代码行数:16,代码来源:AccessController.php

示例13: signUpAction

 public function signUpAction()
 {
     $form = new SignUpForm();
     $this->view->form = $form;
     if (isset($_POST)) {
         if ($form->isValid($_POST)) {
             $user = new UserModel();
             $user->populate($_POST);
             $user->save();
         } else {
             foreach ($form->getMessages() as $message) {
                 $this->flash->error($message);
             }
         }
         // $this->view->disable();
     }
 }
开发者ID:proskills,项目名称:literal-literature,代码行数:17,代码来源:UserController.php

示例14: register

 public function register()
 {
     $reguser = array('regfirst' => Input::get('regfirst'), 'reglast' => Input::get('reglast'), 'reguser' => Input::get('reguser'), 'password' => Input::get('password'), 'cpassword' => Input::get('cpassword'));
     $rules = array('regfirst' => 'alpha_num|max:50', 'reglast' => 'alpha_num|max:50', 'reguser' => 'required|unique:users,username|alpha_num|min:5', 'password' => 'required|alpha_num|between:6,100', 'cpassword' => 'required|alpha_num|between:6,100|same:password');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::Back()->withInput()->withErrors($validator);
     } else {
         $user = new UserModel();
         $user->firstname = Input::get('regfirst');
         $user->lastname = Input::get('reglast');
         $user->username = Input::get('reguser');
         $user->password = Hash::make(Input::get('password'));
         $user->roles = Input::get('roles');
         $user->save();
     }
     return Redirect::route('login')->with('flash_notice', 'You are successfully Register.');
 }
开发者ID:shineirvin,项目名称:projectinv.github.io,代码行数:18,代码来源:UserController.php

示例15: actionRegistration

 protected static function actionRegistration()
 {
     if (empty($_POST)) {
         self::redirect(App::getLink('Auth'));
     }
     $errors = array();
     if (empty($_POST['name'])) {
         $errors['name'] = App::t('Введите имя');
     }
     if (empty($_POST['email'])) {
         $errors['email'] = App::t('Введите email');
     } else {
         if (!preg_match('/^[-A-Za-z0-9_\\.]+@[-A-Za-z0-9_\\.]+\\.[a-z0-9]{2,4}$/', $_POST['email'])) {
             $errors['email'] = App::t('Некорректный email');
         }
     }
     if (empty($_POST['password'])) {
         $errors['password'] = App::t('Введите пароль');
     } else {
         if (empty($_POST['confirm'])) {
             $errors['confirm'] = App::t('Введите подтверждение');
         } else {
             if ($_POST['password'] != $_POST['confirm']) {
                 $errors['password'] = $errors['confirm'] = App::t('Пароли не совпадают');
             }
         }
     }
     if (empty($errors) && UserModel::getByEmail($_POST['email'])) {
         $errors['email'] = App::t('Этот email уже используется');
     }
     if (empty($errors)) {
         $user = new UserModel();
         $user->name = $_POST['name'];
         $user->email = $_POST['email'];
         $user->password = md5($_POST['password']);
         $user->save();
         App::currentUser($user);
         self::redirect('/');
     }
     self::templateVar('registration_errors', $errors);
     self::templateVar('post', $_POST);
     return self::displayPage('auth');
 }
开发者ID:swash13,项目名称:shop,代码行数:43,代码来源:Auth.php


注:本文中的UserModel::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。