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


PHP USER::fromDatabase方法代碼示例

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


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

示例1: getAllDispatcherOfficeHours

function getAllDispatcherOfficeHours()
{
    $db = DB::getInstance();
    $Dispatcher_hours = $db->prep_execute('SELECT * FROM Dispatcher_hours;', array());
    // Global list of user & course objects. Prevents unnecessary DB reads.
    global $users, $courses;
    // Array of user - course object pair mappings to be returned.
    $return = array();
    // Loop through all Driver - course key mappings
    foreach ($Dispatcher_hours as $row) {
        // Read user from DB and add to user array if not found in array
        if (!isset($users[$row['email']])) {
            $users[$row['email']] = USER::fromDatabase($row['email']);
        }
        // Read course from DB and add to user array if not found in array
        if (!isset($courses[$row['subj'] . '-' . $row['crse']])) {
            $courses[$row['subj'] . '-' . $row['crse']] = COURSE::fromDatabase($row['subj'], intval($row['crse']));
        }
        // Add Driver - course object pair to return array
        $return[] = ['user' => $users[$row['email']], 'course' => $courses[$row['subj'] . '-' . $row['crse']], 'week_day' => $row['week_day'], 'startTime' => $row['start_time'], 'endTime' => $row['end_time']];
    }
    return $return;
}
開發者ID:akelleher,項目名稱:taxi-app,代碼行數:23,代碼來源:relations.php

示例2: empty

 if (isset($_POST['register'])) {
     $empty = empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['password']) || empty($_POST['isDriver']) || empty($_POST['isDispatcher']) || empty($_POST['isfirstTime']);
     if (isset($_POST['firstName'], $_POST['lastName'], $_POST['email'], $_POST['password'], $_POST['isDriver'], $_POST['isDispatcher'], $_POST['isfirstTime']) && $empty == false) {
         $firstName = mysql_real_escape_string(stripslashes($_POST['firstName']));
         $lastName = mysql_real_escape_string(stripslashes($_POST['lastName']));
         $email = mysql_real_escape_string(stripslashes($_POST['email']));
         $password = mysql_real_escape_string(stripslashes($_POST['password']));
         $isDriver = mysql_real_escape_string(stripslashes($_POST['isDriver']));
         $isDispatcher = mysql_real_escape_string(stripslashes($_POST['isDispatcher']));
         $isfirstTime = mysql_real_escape_string(stripslashes($_POST['isfirstTime']));
         // Transforms strings into boolean values
         $isDriver = $isDriver === 'true' ? true : false;
         $isDispatcher = $isDispatcher === 'true' ? true : false;
         $isfirstTime = $isfirstTime === 'true' ? true : false;
         // If user in database
         if (USER::fromDatabase($email) !== null) {
             echo 1;
         } else {
             $user = User::withValues($email, $password, $isDriver, $isDispatcher, $isfirstTime, false, $firstName, $lastName);
             //var_dump($user);
             if ($user === null) {
                 //check if error instantiating user (password too short)
                 echo 0;
             } else {
                 $user->store();
                 $user->login($password);
                 echo 2;
             }
         }
     }
 }
開發者ID:akelleher,項目名稱:taxi-app,代碼行數:31,代碼來源:validate_login.php

示例3: getAllDispatchers

 public static function getAllDispatchers()
 {
     $allDispatchers = array();
     $db = DB::getInstance();
     $Dispatcher_rows = $db->prep_execute('SELECT email FROM users WHERE isDispatcher = 1;', array());
     foreach ($Dispatcher_rows as $row) {
         $allDispatchers[] = USER::fromDatabase($row['email']);
     }
     return $allDispatchers;
 }
開發者ID:akelleher,項目名稱:taxi-app,代碼行數:10,代碼來源:User.php


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