当前位置: 首页>>代码示例>>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;未经允许,请勿转载。