當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserUtil::getUserById方法代碼示例

本文整理匯總了PHP中UserUtil::getUserById方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserUtil::getUserById方法的具體用法?PHP UserUtil::getUserById怎麽用?PHP UserUtil::getUserById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserUtil的用法示例。


在下文中一共展示了UserUtil::getUserById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: UserUtil

 $UserUtil = new UserUtil($DB);
 $BuildingUtil = new BuildingUtil($DB);
 $user = new User(null, 'example', 'test@test.com');
 $user->setPassword('a-password');
 $user = $UserUtil->create($user);
 if ($user != null) {
     echo '<strong>UserUtil->create()</strong>';
     echo '<pre>';
     print_r($user);
     echo '</pre>';
 } else {
     echo "A problem ocurred while trying to create the user";
 }
 if ($user != null) {
     $id = $user->getId();
     $user2 = $UserUtil->getUserById($id);
     if ($user2 != null) {
         echo '<strong>UserUtil->getUserById()</strong>';
         echo '<pre>';
         print_r($user2);
         echo '</pre>';
     } else {
         echo "A problem ocurred while trying to get a user by ID";
     }
 }
 if ($user != null) {
     if ($UserUtil->removeUser($user)) {
         echo '<strong>UserUtil->remove()</strong>';
         echo '<br />OK';
     } else {
         echo "A problem ocurred while trying to remove the user from the database";
開發者ID:yielruse,項目名稱:Making-Isometric-Real-time-Games,代碼行數:31,代碼來源:test-database.php

示例2: die

// Include class definitions before calling session_start()
require_once '../../server/classes/class.dbutil.php';
require_once '../../server/classes/class.users.php';
require_once '../../server/classes/class.buildings.php';
require_once '../../server/classes/class.operations.php';
require_once '../../server/classes/class.user.php';
require_once '../../server/config.php';
session_start();
if (count($_GET) != 0 && isset($_SESSION['userSession'])) {
    // Check that all parameters have valid values
    if (!is_numeric($_GET['x']) || !is_numeric($_GET['y']) || intval($_GET['x']) < 0 || intval($_GET['y']) < 0 || intval($_GET['x']) > GRID_X || intval($_GET['y']) > GRID_Y) {
        die('ERROR');
    }
    $DB = new DBUtil(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    // DB name
    if ($DB) {
        $UserUtil = new UserUtil($DB);
        $OperUtil = new OperationsUtil($DB);
        $user = $UserUtil->getUserById($_SESSION['userSession']->getId());
        // Is there anything in that coordinate?
        $inst = $OperUtil->findBuildingInstanceByXY($user->getId(), $_GET['x'], $_GET['y']);
        if ($inst) {
            $OperUtil->removeInstance($inst);
            die('OK');
        } else {
            die('ERROR');
        }
    }
} else {
    die('ERROR');
}
開發者ID:yielruse,項目名稱:Making-Isometric-Real-time-Games,代碼行數:31,代碼來源:demolish.php


注:本文中的UserUtil::getUserById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。