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


PHP UserMapper::findByName方法代码示例

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


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

示例1: login

 /**
  * Tries to log the user using the username and password received in the post.
  */
 function login()
 {
     $text = $this->icfTemplating->getText();
     $username = $_POST["username"];
     $password = $_POST["password"];
     // No data for login...
     if ($username == "") {
         $this->controllerData["loginfailed"] = $text["incorrectinput"];
         $this->show_view();
         return;
     }
     // Get the user
     $userMapper = new UserMapper();
     $user = $userMapper->findByName($username);
     if ($user != null) {
         // The user exists, validate the password
         $login = $user->login($password);
         if ($login) {
             // User logged in !! register it in the session
             $session = new Session($user);
             // Redirect to home
             $this->show_home_view();
             return;
         }
     }
     // The login has failed, send the error
     $this->controllerData["loginfailed"] = $text["loginfailed"];
     // .. and display the data that the user gave to us
     $this->controllerData["username"] = $username;
     $this->controllerData["password"] = $password;
     $this->show_view();
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:35,代码来源:loginController.php

示例2: json_encode

<?php

$rootPass = dirname(__FILE__) . '/../../';
require_once $rootPass . 'lib/db/dbfunctions.php';
require_once $rootPass . 'lib/db/Model/User.php';
require_once $rootPass . 'lib/db/Mapper/UserMapper.php';
$pdo = getPDO($argv[2]);
$umapper = new UserMapper($pdo);
$user = $umapper->findByName($argv[1]);
$userArray = (array) $user;
foreach ($userArray as $value) {
    // オブジェクトのネストを解消(だいぶ汚いので後で直す)
    $userArray = $value;
    break;
}
header("Content-Type: application/json; charset=utf-8");
echo json_encode((array) $userArray);
// echo json_encode($result);
开发者ID:shimizu9128,项目名称:nfcCheckin,代码行数:18,代码来源:getUserByName.php

示例3: testFindByName

 public function testFindByName()
 {
     $userName = "forFindByNameUser";
     $userName2 = "otherUser";
     $user = getUserInstance($userName);
     $user2 = getUserInstance($userName2);
     $umapper = new UserMapper(self::$pdo);
     $umapper->insert($user);
     $umapper->insert($user2);
     $newUser = $umapper->findByName($user->user_name);
     $this->assertEquals($newUser->user_name, $userName);
 }
开发者ID:shimizu9128,项目名称:nfcCheckin,代码行数:12,代码来源:UserMapperTest.php


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