本文整理汇总了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;
}
示例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;
}
}
}
}
示例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;
}