本文整理汇总了PHP中PHPWS_DB::addOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::addOrder方法的具体用法?PHP PHPWS_DB::addOrder怎么用?PHP PHPWS_DB::addOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_DB
的用法示例。
在下文中一共展示了PHPWS_DB::addOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reappAvailability
/**
* Report lists rooms in each residence hall that are still available, along with
* the available beds in the room. Also, show the number of beds allocated to the
* lotter for each residence hall.
*
*/
public static function reappAvailability()
{
$term = Term::getSelectedTerm();
// Available rooms in each residence hall.
$db = new PHPWS_DB('hms_bed');
$db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
$db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
$db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
//$db->addWhere('hms_bed.ra_bed', 0);
$db->addWhere('hms_room.private', 0);
$db->addWhere('hms_room.overflow', 0);
$db->addWhere('hms_room.reserved', 0);
$db->addWhere('hms_room.offline', 0);
$db->addWhere('hms_bed.term', $term);
$db->addColumn('hms_room.room_number');
$db->addColumn('hms_bed.bed_letter', null, null, True);
$db->addColumn('hms_residence_hall.hall_name');
$db->addGroupBy('hms_residence_hall.hall_name');
$db->addGroupBy('hms_room.room_number');
$db->addOrder('hms_residence_hall.hall_name');
$availRooms = $db->select();
// Allocated beds for lottery.
$db = new PHPWS_DB('hms_bed');
$db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
$db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
$db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
$db->addJoin('RIGHT', 'hms_bed', 'hms_lottery_reservation', 'id', 'bed_id');
$db->addWhere('hms_lottery_reservation.term', $term);
$db->addColumn('hms_residence_hall.hall_name');
$db->addColumn('hms_bed.id', null, null, True);
$db->addGroupBy('hms_residence_hall.hall_name');
$db->setIndexBy('hall_name');
$lotteryBeds = $db->select();
$tpl = new PHPWS_Template('hms');
$tpl->setFile('admin/reports/reapp_availability.tpl');
//
// "The parent row must be parsed after the child rows."
// Preload currHall with first residence hall name
$currHall = $availRooms[0]['hall_name'];
foreach ($availRooms as $row) {
// Change halls, create new block.
if ($currHall != $row['hall_name'] || $currHall == null) {
$tpl->setCurrentBlock('halls');
// Get allocated beds for the residence hall.
$lottCount = isset($lotteryBeds[$currHall]['count']) ? $lotteryBeds[$currHall]['count'] : 0;
$tpl->setData(array('HALL_NAME' => $currHall, 'LOTTERY_BEDS' => $lottCount));
$tpl->parseCurrentBlock();
$currHall = $row['hall_name'];
}
// Add room to residence hall template block.
$tpl->setCurrentBlock('rooms');
$tpl->setData(array('ROOM_NUM' => $row['room_number'], 'BED_COUNT' => $row['count']));
$tpl->parseCurrentBlock();
}
// Get last residence hall. Can't parse parent before child with template class.
$tpl->setCurrentBlock('halls');
$tpl->setData(array('HALL_NAME' => $currHall));
$tpl->parseCurrentBlock();
return $tpl->get();
}
示例2: processAll
public static function processAll($term)
{
$db = new PHPWS_DB('hms_banner_queue');
$db->addWhere('term', $term);
$db->addOrder('id');
$items = $db->getObjects('BannerQueueItem');
$errors = array();
foreach ($items as $item) {
$result = null;
try {
$result = $item->process();
} catch (Exception $e) {
$error = array();
$error['username'] = $item->asu_username;
$error['code'] = $e->getCode();
$error['message'] = $e->getMessage();
$errors[] = $error;
continue;
}
if ($result === TRUE) {
$item->delete();
}
}
if (empty($errors)) {
return TRUE;
}
return $errors;
}
示例3: execute
public function execute()
{
PHPWS_Core::initModClass('hms', 'HMS_Util.php');
$term = $this->term;
$db = new PHPWS_DB('hms_checkin');
// Join hall structure
$db->addJoin('', 'hms_checkin', 'hms_hall_structure', 'bed_id', 'bedid');
$db->addColumn('hms_checkin.banner_id');
$db->addColumn('hms_checkin.checkin_date');
$db->addColumn('hms_hall_structure.hall_name');
$db->addColumn('hms_hall_structure.room_number');
$db->addWhere('hms_checkin.term', $term);
$db->addWhere('hms_checkin.checkout_date', null, 'IS NULL');
// Sort by hall, then room number
$db->addOrder(array('hms_hall_structure.hall_name ASC', 'hms_hall_structure.room_number ASC'));
$results = $db->select();
if (PHPWS_Error::isError($results)) {
throw new DatabaseException($results->toString());
}
// Post-processing, cleanup, making it pretty
foreach ($results as $row) {
// Updates counts
$this->total++;
$row['checkin_date'] = HMS_Util::get_short_date_time($row['checkin_date']);
// Copy the cleaned up row to the member var for data
$this->data[] = $row;
}
}
示例4: execute
/**
* Executes this pulse. Checks for any pending reports and runs them.
*/
public static function execute()
{
// Reschedule the next run of this process
/*
$sp = $this->makeClone();
$sp->execute_at = strtotime("+1 minutes");
$sp->save();
*
*/
// Load necessary classes
PHPWS_Core::initModClass('hms', 'UserStatus.php');
PHPWS_Core::initModClass('hms', 'ReportFactory.php');
PHPWS_Core::initModCLass('hms', 'HMS_Email.php');
// Fake a user, in case we need that
UserStatus::wearMask('HMS System');
// Check for any pending reports (scheduled for any time up until now)
$db = new PHPWS_DB('hms_report');
$db->addWhere('completed_timestamp', null, 'IS');
// not completed
$db->addWhere('began_timestamp', null, 'IS');
// not already running somewhere
$db->addWhere('scheduled_exec_time', time(), '<=');
// scheduled exec time is now or before
$db->addOrder('scheduled_exec_time ASC');
// Run in order scheduled
$results = $db->select();
// If there's nothing to do, quite nicely
if (!isset($results) || is_null($results) || empty($results)) {
UserStatus::removeMask();
return 'No reports waiting.';
}
// Run each report
foreach ($results as $row) {
$report = null;
try {
// Load the proper controller for this report
$reportCtrl = ReportFactory::getControllerById($row['id']);
// Load this report's params
$reportCtrl->loadParams();
// Generate the report
$reportCtrl->generateReport();
$report = $reportCtrl->getReport();
} catch (Exception $e) {
// handle the exception nicely
self::emailError(self::formatException($e));
exit;
}
// Send success notification
$username = $report->getCreatedBy();
if ($username == 'jbooker') {
$username = 'jb67803';
}
HMS_Email::sendReportCompleteNotification($username, $report->getFriendlyName());
}
// Remove the mask
UserStatus::removeMask();
// Exit cleanly
return;
}
示例5: getChangesForInternship
public static function getChangesForInternship(Internship $internship)
{
$db = new \PHPWS_DB('intern_change_history');
$db->addWhere('internship_id', $internship->getId());
$db->addOrder('timestamp ASC');
$results = $db->getObjects('\\Intern\\ChangeHistory');
if (\PHPWS_Error::logIfError($results)) {
throw new \Exception($results->toString());
}
return $results;
}
示例6: getChangesForInternship
public static function getChangesForInternship(Internship $internship)
{
PHPWS_Core::initModClass('intern', 'ChangeHistory.php');
$db = new PHPWS_DB('intern_change_history');
$db->addWhere('internship_id', $internship->getId());
$db->addOrder('timestamp ASC');
$results = $db->getObjects('ChangeHistory');
if (PHPWS_Error::logIfError($results)) {
throw new Exception($results->toString());
}
return $results;
}
示例7: init
/**
* initialize this object (fill the array) with assignment histories
*
* @param int $bannerID banner id of student
* @param int $term term to be searching
* @return boolean flag to signal if the initialization was a success
*/
private function init()
{
$db = new PHPWS_DB('hms_assignment_history');
$db->addWhere('banner_id', $this->bannerId);
$db->loadClass('hms', 'AssignmentHistory.php');
$db->addOrder(array('term DESC', 'assigned_on DESC'));
$result = $db->getObjects('AssignmentHistory');
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
if (isset($result)) {
$this->assignmentHistory = $result;
}
return true;
}
示例8: getHallList
private function getHallList()
{
$db = new PHPWS_DB('hms_residence_hall');
$db->addColumn('id');
$db->addColumn('hall_name');
$db->addWhere('term', $this->term);
$db->addWhere('is_online', 1);
// only get halls that are online
$db->addOrder('hall_name', 'asc');
$result = $db->select();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
return $result;
}
示例9: getSubjects
public static function getSubjects($mustIncludeId = null)
{
$subjects = array('-1' => 'Select a subject...');
$db = new PHPWS_DB('intern_subject');
$db->addWhere('active', 1, '=', 'OR');
if (!is_null($mustIncludeId)) {
$db->addWhere('id', $mustIncludeId, '=', 'OR');
}
$db->addOrder('abbreviation ASC');
$results = $db->select();
foreach ($results as $row) {
$subjects[$row['id']] = $row['abbreviation'] . ' - ' . $row['description'];
}
return $subjects;
}
示例10: getAllowedStates
public static function getAllowedStates()
{
$db = new \PHPWS_DB('intern_state');
$db->addWhere('active', 1);
$db->addColumn('abbr');
$db->addColumn('full_name');
$db->setIndexBy('abbr');
$db->addOrder('full_name ASC');
$states = $db->select('col');
if (empty($states)) {
\NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
\NQ::close();
PHPWS_Core::goBack();
}
return $states;
}
示例11: display
public static function display()
{
javascriptMod('intern', 'pick_state');
$db = new PHPWS_DB('intern_state');
$db->addOrder('full_name');
$states = $db->select();
foreach ($states as $state) {
extract($state);
//abbr, full_name, active
$row = array('ABBR' => $abbr, 'NAME' => $full_name);
if (!$active) {
$tpl['state_row'][] = $row;
} else {
$tpl['active_row'][] = $row;
}
}
return PHPWS_Template::process($tpl, 'intern', 'state_list.tpl');
}
示例12: getRlcList
/**
* Returns an associative array containing the list of RLCs using their full names, keyed by their id.
*
* @param int $term
* @param string $studentType
* @param string $hidden
* @throws DatabaseException
* @return Array Array of communities
*/
public static function getRlcList($term, $studentType = NULL, $hidden = NULL)
{
$db = new PHPWS_DB('hms_learning_communities');
$db->addColumn('id');
$db->addColumn('community_name');
if (!is_null($studentType) && strlen($studentType) == 1) {
$db->addWhere('allowed_student_types', "%{$student_type}%", 'ilike');
}
if ($hidden === FALSE) {
$db->addWhere('hide', 0);
}
$db->addOrder('community_name ASC');
$rlcs = $db->select('assoc');
if (PHPWS_Error::logIfError($rlcs)) {
throw new DatabaseException($rlcs->toString());
}
return $rlcs;
}
示例13: execute
public function execute()
{
if (!isset($this->term) || is_null($this->term)) {
throw new InvalidArgumentException('Missing term.');
}
/*****
* Total Beds
*/
$db = new PHPWS_DB('hms_bed');
$db->addJoin('', 'hms_bed', 'hms_room', 'room_id', 'id');
$db->addJoin('', 'hms_room', 'hms_floor', 'floor_id', 'id');
$db->addJoin('', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
$db->addWhere('hms_bed.term', $this->term);
$this->totalBedCount = $db->count();
if (PHPWS_Error::logIfError($this->totalBedCount)) {
PHPWS_Core::initModClass('hms', 'exception', 'DatabaseException.php');
throw new DatabaseException($this->totalBedCount->toString());
}
/*******
* Unavailable Beds
*/
$db = new PHPWS_DB('hms_bed');
$db->addColumn('hms_residence_hall.hall_name');
$db->addColumn('hms_bed.*');
$db->addColumn('hms_room.*');
$db->addJoin('', 'hms_bed', 'hms_room', 'room_id', 'id');
$db->addJoin('', 'hms_room', 'hms_floor', 'floor_id', 'id');
$db->addJoin('', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
$db->addWhere('hms_room.reserved', 1, null, 'OR', 'foo');
$db->addWhere('hms_room.ra', 1, null, 'OR', 'foo');
$db->addWhere('hms_room.private', 1, null, 'OR', 'foo');
$db->addWhere('hms_room.overflow', 1, null, 'OR', 'foo');
$db->addWhere('hms_room.parlor', 1, null, 'OR', 'foo');
$db->addWhere('hms_room.offline', 1, null, 'OR', 'foo');
$db->addWhere('hms_bed.ra_roommate', 1, null, 'OR', 'foo');
$db->addWhere('hms_bed.international_reserved', 1, null, 'OR', 'foo');
$db->addWhere('hms_bed.term', $this->term);
$db->addOrder(array('hms_residence_hall.hall_name', 'hms_room.room_number', 'bed_letter'));
$this->unavailableBeds = $db->select();
if (PHPWS_Error::logIfError($this->unavailableBeds)) {
PHPWS_Core::initModClass('hms', 'exception/DatabaseException.php');
throw new DatabaseException($this->unavailableBeds->toString());
}
}
示例14: getAllowedStates
public static function getAllowedStates()
{
$db = new PHPWS_DB('intern_state');
$db->addWhere('active', 1);
$db->addColumn('abbr');
$db->addColumn('full_name');
$db->setIndexBy('abbr');
// get backwards because we flip it
$db->addOrder('full_name desc');
$states = $db->select('col');
if (empty($states)) {
NQ::simple('intern', INTERN_ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
NQ::close();
PHPWS_Core::goBack();
}
$states[-1] = 'Select a state';
$states = array_reverse($states, true);
return $states;
}
示例15: loadPeeps
public function loadPeeps($registered = true)
{
PHPWS_Core::initModClass('signup', 'Peeps.php');
$db = new PHPWS_DB('signup_peeps');
$db->addWhere('slot_id', $this->id);
if ($registered) {
$db->addWhere('registered', 1);
} else {
$db->addWhere('registered', 0);
}
$db->addOrder('last_name');
$peeps = $db->getObjects('Signup_Peep');
if (PHPWS_Error::logIfError($peeps)) {
return false;
} else {
$this->_peeps =& $peeps;
return true;
}
}