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


PHP UserMapper::update方法代码示例

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


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

示例1: testUpdateUser

 public function testUpdateUser()
 {
     $umapper = new UserMapper(self::$pdo);
     $user = getUserInstance('user');
     $umapper->insert($user);
     // phpは、オブジェクトを参照渡しするので、insert後のuserオブジェクトをチェックすればよい
     $this->assertArrayHasKey('user_id', $user->toArray());
     $user->user_name = 'updateUser';
     $umapper->update($user);
     // DBに保存されているかどうかを調べる
     $user = $umapper->find($user->user_id);
     $this->assertSame('updateUser', $user->user_name);
 }
开发者ID:shimizu9128,项目名称:nfcCheckin,代码行数:13,代码来源:UserMapperTest.php

示例2: update

 public function update()
 {
     $userid = $_REQUEST["usuario"];
     $user = $this->userMapper->findById($userid);
     $errors = array();
     $pass = md5($_POST["passActual"]);
     if ($this->userMapper->isValidUser($_POST["usuario"], $pass)) {
         if (isset($_POST["usuario"])) {
             $user->setNombre($_POST["nombre"]);
             $user->setApellidos($_POST["apellidos"]);
             $user->setCorreo($_POST["correo"]);
             if (isset($_FILES['img'])) {
                 $img = $_FILES['img']['name'];
                 $ext = strrchr($img, '.');
                 $ruta = 'imagenes/user_' . $user->getId() . $ext;
                 if (move_uploaded_file($_FILES['img']['tmp_name'], $ruta)) {
                     $user->setImagen($user->getId() . $ext);
                 }
             }
             if (!(strlen(trim($_POST["passNew"])) == 0)) {
                 if ($_POST["passNew"] == $_POST["passNueva"]) {
                     $passNew = md5($_POST["passNew"]);
                     $user->setPassword($passNew);
                 } else {
                     $errors["pass"] = i18n("Passwords must be equal");
                     $this->view->setVariable("errors", $errors);
                     $this->view->setVariable("user", $user);
                     $this->view->render("users", "modificar");
                     return false;
                 }
             }
             try {
                 $this->userMapper->update($user);
                 $this->view->setFlash(i18n("Modified user correctly"));
                 $this->view->redirect("users", "perfil");
             } catch (ValidationException $ex) {
                 $errors = $ex->getErrors();
                 $this->view->setVariable("errors", $errors);
             }
         }
     } else {
         $errors["passActual"] = i18n("Incorrect password");
         $this->view->setVariable("errors", $errors);
         $this->view->setVariable("user", $user);
         $this->view->render("users", "modificar");
     }
 }
开发者ID:xrlopez,项目名称:TSW,代码行数:47,代码来源:UsersController.php

示例3: update

 public static function update($email, $pass, $name, $avatar, $typeuser, $curriculum, $direccion, $web, $horario, $imagen, $geoloc)
 {
     UserMapper::update($email, $pass, $name, $avatar, $typeuser, $curriculum, $direccion, $web, $horario, $imagen, $geoloc);
 }
开发者ID:ndrs92,项目名称:PinchoWire,代码行数:4,代码来源:usuario.php

示例4: connectDatabase

    // バリデーション
    if ($name == '') {
        $errors['name'] = 'ユーザーネームが未入力です';
    }
    if ($email == '') {
        $errors['email'] = 'メールアドレスが未入力です';
    }
    // バリデーション突破後
    if (empty($errors)) {
        $dbh = connectDatabase();
        $user_mapper = new UserMapper(connectDatabase);
        $login_form = ['name' => $name, 'email' => $email];
        $user = $user_mapper->login($login_form);
        if ($user) {
            $user->incrementLoginCount();
            $user_mapper->update($user);
            $_SESSION['user'] = serialize($user);
            header('Location: index.php');
            exit;
        } else {
            echo 'ユーザーネームかメールアドレスが間違っています';
        }
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ログイン画面</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
开发者ID:ogontaro,项目名称:elites-output,代码行数:31,代码来源:login.php

示例5: sizeof

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once "Autoloader.php";
$db = new PdoAdapter();
$userMapper = new UserMapper($db);
$articleMapper = new ArticleMapper($db);
//get user by username
$user = $userMapper->findOne(array("conditions" => array('username = ? ', "john doe")));
echo "Username: " . $user->username;
echo "<br />Articles of this user:<br />";
foreach ($user->articles as $article) {
    echo $article->title . '<br />';
}
//edit the user
$user->username = "johnny doe";
$userMapper->update($user);
//add a new user
$newUser = new User();
$newUser->username = "my username 2";
$userMapper->insert($newUser);
//delete a user
$userMapper->delete(4);
//get users with their articles
//get all users limited by 2, sorted by username ascending and eager load the article relationship
//only 2 queries - one for fetching the users and one for coupling the related articles
$users = $userMapper->findMany(array("limit" => 3, "sort" => array("username", "asc"), "relations" => array("Article")));
//4 queries: one for retrieving the users and 1 per user lazy loading the articles.
$users = $userMapper->findMany(array("limit" => 3, "sort" => array("username", "asc")));
echo sizeof($users) . " users found<br />";
foreach ($users as $user) {
    echo "<br />Username:" . $user->username . "<br />";
开发者ID:bartronix,项目名称:orm,代码行数:31,代码来源:index.php

示例6: modifyAction

 public function modifyAction($I_id)
 {
     $this->isAdmin();
     $S_login = $_POST['login'];
     if (isset($_POST['sendPassword'])) {
         $B_password = $_POST['sendPassword'];
     }
     $S_name = $_POST['name'];
     $S_firstName = $_POST['firstName'];
     if (isset($_POST['sizeHarness'])) {
         $I_sizeHarness = $_POST['sizeHarness'];
     }
     $S_email = $_POST['email'];
     if (isset($_POST['company_id'])) {
         $I_company_id = $_POST['company_id'];
     }
     if (isset($_POST['subgroup_id'])) {
         $I_subgroup_id = $_POST['subgroup_id'];
     }
     if (isset($_POST['staff_id'])) {
         $I_staff_id = $_POST['staff_id'];
     }
     if (isset($_POST['profile'])) {
         $S_profile = $_POST['profile'];
     }
     $O_userMapper = new UserMapper();
     $O_user = $O_userMapper->findById($I_id);
     if (isset($_SESSION['token'])) {
         if ($_POST['token'] == $_SESSION['token']) {
             // OK - Je peux faire le traitement
             // avons nous un operator ?
             if (isset($_POST['operator']) && !isset($_POST['inspector'])) {
                 // si aucune modification de faite pas la peine de le lancer une requete
                 if ($S_login != $O_user->getLogin() || $S_name != $O_user->getOperator()->getName() || $S_firstName != $O_user->getOperator()->getFirstName() || $I_sizeHarness != $O_user->getOperator()->getSizeHarness() || $S_email != $O_user->getOperator()->getEmail() || $I_company_id != $O_user->getOperator()->getTeam()->getSubgroup()->getCompany()->getId() || $I_subgroup_id != $O_user->getOperator()->getTeam()->getSubgroup()->getId() || $I_staff_id != $O_user->getOperator()->getTeam()->getstaff()->getId() || isset($S_profile) && $S_profile != $O_user->getProfile()->getName()) {
                     // je mets à jour le login du user:
                     $O_user->setLogin($S_login);
                     // Pour mettre à jour la variable $profile_id et l'objet profile contenu dans l'objet user :
                     $O_profileMapper = new ProfileMapper();
                     $O_profile = $O_profileMapper->findByName($S_profile);
                     $O_user->setProfile($O_profile);
                     $O_user->setProfileId($O_user->getProfile()->getId());
                     // Pour mettre à jour l'operateur lié à l'utilisateur
                     $O_operatorMapper = new OperatorMapper();
                     $O_operator = $O_operatorMapper->findById($O_user->getOperatorId());
                     $O_operator->setName($S_name);
                     $O_operator->setFirstName($S_firstName);
                     $O_operator->setSizeHarness($I_sizeHarness);
                     $O_operator->setEmail($S_email);
                     // Pour cherché la team concerné par le subgroup et le staff
                     $O_teamMapper = new TeamMapper();
                     $O_team = $O_teamMapper->findByTwoIds($I_staff_id, $I_subgroup_id);
                     // Pour cherché le sous groupe concerné
                     $O_subgroupMapper = new SubgroupMapper();
                     $O_subgroup = $O_subgroupMapper->findById($I_subgroup_id);
                     // Pour cherché le staff
                     $O_staffMapper = new StaffMapper();
                     $O_staff = $O_staffMapper->findById($I_staff_id);
                     // On donne à l'objet Team son objet Staff et Subgroup
                     $O_team->setStaff($O_staff);
                     $O_team->setSubgroup($O_subgroup);
                     // On donne à l'opérateur sa team
                     $O_operator->setTeamId($O_team->getId());
                     $O_operator->setTeam($O_team);
                     // On donne à l'utilisateur son opérateur
                     $O_user->setOperator($O_operator);
                     try {
                         // on donne l'objet user pour la mise à jour
                         $O_userMapper->update($O_user);
                         // on donne l'objet operator pour la mise à jour
                         $O_operatorMapper->update($O_operator);
                         die(header('Location:/user/default/'));
                     } catch (Exception $e) {
                         Session::setSession('error', $e->getMessage());
                     }
                 } elseif ($B_password == true) {
                     $this->sendPasswordAction($S_email);
                     $O_userMapper->changePassword($O_user, $this->S_password);
                     die(header('Location:/user/default/'));
                 } else {
                     die(header('Location:/user/edit/' . $I_id));
                 }
             } elseif (!isset($_POST['operator']) && isset($_POST['inspector'])) {
                 // si aucune modification de faite pas la peine de le lancer une requete
                 if ($S_login != $O_user->getLogin() || $S_name != $O_user->getInspector()->getName() || $S_firstName != $O_user->getInspector()->getFirstName() || $S_email != $O_user->getInspector()->getEmail() || isset($S_profile) && $S_profile != $O_user->getProfile()->getName()) {
                     // je mets à jour le login du user:
                     $O_user->setLogin($S_login);
                     // Pour mettre à jour la variable $profile_id et l'objet profile contenu dans l'objet user :
                     $O_profileMapper = new ProfileMapper();
                     $O_profile = $O_profileMapper->findByName($S_profile);
                     $O_user->setProfile($O_profile);
                     $O_user->setProfileId($O_user->getProfile()->getId());
                     // Pour mettre à jour l'inspecteur lié à l'utilisateur
                     $O_inspectorMapper = new InspectorMapper();
                     $O_inspector = $O_inspectorMapper->findById($O_user->getinspectorId());
                     $O_inspector->setName($S_name);
                     $O_inspector->setFirstName($S_firstName);
                     $O_inspector->setEmail($S_email);
                     // On donne à l'utilisateur son inspecteur
                     $O_user->setInspector($O_inspector);
                     try {
//.........这里部分代码省略.........
开发者ID:Vincent-Troccaz,项目名称:safety,代码行数:101,代码来源:ControllerUser.php


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