当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPWS_DB::count方法代码示例

本文整理汇总了PHP中PHPWS_DB::count方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::count方法的具体用法?PHP PHPWS_DB::count怎么用?PHP PHPWS_DB::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPWS_DB的用法示例。


在下文中一共展示了PHPWS_DB::count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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());
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:44,代码来源:UnavailableBeds.php

示例2: queueRemoveAssignment

 /**
  * Queues a Remove Assignment
  *
  * NOTE: If the queue contains a Create Assignment for the same
  * user to the same room, this will NOT queue a room assignment,
  * but rather will delete the original assignment, UNLESS the
  * $force_queue flag is set.  The $force_queue flag being true will
  * queue a removal no matter what.
  *
  * MORE NOTE: If this requires immediate processing because banner
  * commits are enabled, the it will be sent straight to Banner,
  * and so the force_queue flag will be ignored.
  */
 public static function queueRemoveAssignment(Student $student, $term, HMS_Residence_Hall $hall, HMS_Bed $bed, $refund)
 {
     $entry = new BannerQueueItem(0, BANNER_QUEUE_REMOVAL, $student, $term, $hall, $bed, null, null, $refund);
     if (BannerQueue::processImmediately($term)) {
         return $entry->process();
     }
     // Otherwise, look for an corresponding assignment
     $db = new PHPWS_DB('hms_banner_queue');
     $db->addWhere('type', BANNER_QUEUE_ASSIGNMENT);
     $db->addWhere('asu_username', $student->getUsername());
     $db->addWhere('building_code', $hall->getBannerBuildingCode());
     $db->addWhere('bed_code', $bed->getBannerId());
     $db->addWhere('term', $term);
     $result = $db->count();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     if ($result == 0) {
         return $entry->save();
     } else {
         return $db->delete();
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:36,代码来源:BannerQueue.php

示例3: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit terms.');
     }
     $successCmd = CommandFactory::getCommand('ShowEditTerm');
     $errorCmd = CommandFactory::getCommand('ShowCreateTerm');
     $year = $context->get('year_drop');
     $sem = $context->get('term_drop');
     if (!isset($year) || is_null($year) || empty($year)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must provide a year.');
         $errorCmd->redirect();
     }
     if (!isset($sem) || is_null($sem) || empty($sem)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must provide a semester.');
         $errorCmd->redirect();
     }
     // Check to see if the specified term already exists
     if (!Term::isValidTerm($year . $sem)) {
         $term = new Term(NULL);
         $term->setTerm($year . $sem);
         $term->setBannerQueue(1);
         try {
             $term->save();
         } catch (DatabaseException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error saving the term. Please try again or contact ESS.');
             $errorCmd->redirect();
         }
     } else {
         $term = new Term($year . $sem);
         // The term already exists, make sure there are no halls for this term
         $db = new PHPWS_DB('hms_residence_hall');
         $db->addWhere('term', $term->getTerm());
         $num = $db->count();
         if (!is_null($num) && $num > 0) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'One or more halls already exist for this term, so nothing can be copied.');
             $errorCmd->redirect();
         }
     }
     $text = Term::toString($term->getTerm());
     $copy = $context->get('copy_pick');
     $copyAssignments = false;
     $copyRoles = false;
     // If you want to copy roles and/or assignments
     // you must also copy the hall structure.
     if (isset($copy['struct'])) {
         // Copy hall structure
         if (isset($copy['assign'])) {
             // Copy assignments.
             $copyAssignments = true;
         }
         if (isset($copy['role'])) {
             // Copy roles.
             $copyRoles = true;
         }
     } else {
         // either $copy == 'nothing', or the view didn't specify... either way, we're done
         NQ::simple('hms', hms\NotificationView::SUCCESS, "{$text} term created successfully.");
         $successCmd->redirect();
     }
     # Figure out which term we're copying from, if there isn't one then use the "current" term.
     $fromTerm = $context->get('from_term');
     if (is_null($fromTerm)) {
         $fromTerm = Term::getCurrentTerm();
     }
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $db = new PHPWS_DB();
     try {
         $db->query('BEGIN');
         # Get the halls from the current term
         $halls = HMS_Residence_Hall::get_halls($fromTerm);
         set_time_limit(36000);
         foreach ($halls as $hall) {
             $hall->copy($term->getTerm(), $copyAssignments, $copyRoles);
         }
         $db->query('COMMIT');
     } catch (Exception $e) {
         $db->query('ROLLBACK');
         PHPWS_Error::log(print_r($e, true), 'hms');
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error copying the hall structure and/or assignments. The term was created, but nothing was copied.');
         $errorCmd->redirect();
     }
     if ($copyAssignments) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, "{$text} term created successfully. The hall structure and assignments were copied successfully.");
     } else {
         NQ::simple('hms', hms\NotificationView::SUCCESS, "{$text} term created successfully and hall structure copied successfully.");
     }
     Term::setSelectedTerm($term->getTerm());
     $successCmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:92,代码来源:CreateTermCommand.php

示例4: getPanel

 public function getPanel()
 {
     $panel = new PHPWS_Panel('calendar');
     $vars['aop'] = 'schedules';
     $tabs['schedules'] = array('title' => dgettext('calendar', 'Schedules'), 'link' => PHPWS_Text::linkAddress('calendar', $vars));
     if (Current_User::allow('calendar', 'settings')) {
         $vars['aop'] = 'settings';
         $tabs['settings'] = array('title' => dgettext('calendar', 'Settings'), 'link' => PHPWS_Text::linkAddress('calendar', $vars));
     }
     if (Current_User::isUnrestricted('calendar') && Current_User::allow('calendar', 'edit_public')) {
         $vars['aop'] = 'approval';
         $db = new PHPWS_DB('calendar_suggestions');
         $count = $db->count();
         if (PHPWS_Error::isError($count)) {
             PHPWS_Error::log($count);
             $count = 0;
         }
         $tabs['approval'] = array('title' => sprintf(dgettext('calendar', 'Approval (%s)'), $count), 'link' => PHPWS_Text::linkAddress('calendar', $vars));
     }
     $panel->quickSetTabs($tabs);
     return $panel;
 }
开发者ID:par-orillonsoft,项目名称:phpwebsite,代码行数:22,代码来源:Admin.php

示例5: getDiffOptions

 function getDiffOptions()
 {
     $links = array();
     if (!$this->getVrCurrent()) {
         $db = new PHPWS_DB('wiki_pages_version');
         $db->addWhere('source_id', $this->getSourceId());
         $links[] = PHPWS_Text::moduleLink(dgettext('wiki', 'Current'), 'wiki', array('page' => $this->getTitle(FALSE), 'page_op' => 'compare', 'oVer' => $this->getVrNumber(), 'nVer' => $db->count()));
     }
     $db2 = new PHPWS_DB('wiki_pages_version');
     $db2->addWhere('source_id', $this->getSourceId());
     $db2->addColumn('vr_number', 'min');
     if ($this->getVrNumber() != $db2->select('min')) {
         $links[] = PHPWS_Text::moduleLink(dgettext('wiki', 'Previous'), 'wiki', array('page' => $this->getTitle(FALSE), 'page_op' => 'compare', 'oVer' => $this->getVrNumber() - 1, 'nVer' => $this->getVrNumber()));
     }
     return implode(' | ', $links);
 }
开发者ID:Jopperi,项目名称:wiki,代码行数:16,代码来源:OldWikiPage.php

示例6: tallyItems

 public function tallyItems()
 {
     if ($this->ftype == IMAGE_FOLDER) {
         $db = new PHPWS_DB('images');
     } elseif ($this->ftype == DOCUMENT_FOLDER) {
         $db = new PHPWS_DB('documents');
     } elseif ($this->ftype == MULTIMEDIA_FOLDER) {
         $db = new PHPWS_DB('multimedia');
     }
     $db->addWhere('folder_id', $this->id);
     return $db->count();
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:12,代码来源:Folder.php

示例7: countPendingRequests

 /**
  * Returns a count of pending requests
  */
 public static function countPendingRequests($asu_username, $term)
 {
     $db = new PHPWS_DB('hms_roommate');
     $db->addWhere('requestee', $asu_username, 'ILIKE');
     $db->addWhere('confirmed', 0);
     $db->addWhere('term', $term);
     $db->addWhere('requested_on', time() - ROOMMATE_REQ_TIMEOUT, '>=');
     $result = $db->count();
     return $result;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:13,代码来源:HMS_Roommate.php

示例8: isOrphaned

 function isOrphaned()
 {
     $db = new PHPWS_DB('wiki_pages');
     $db->addWhere('pagetext', '%' . $this->getTitle(FALSE) . '%', 'LIKE');
     $db->addWhere('id', $this->getId(), '!=');
     if ($db->count()) {
         return PHPWS_Text::moduleLink(dgettext('wiki', 'No'), 'wiki', array('page' => $this->getTitle(FALSE), 'page_op' => 'whatlinkshere'));
     }
     return dgettext('wiki', 'Yes');
 }
开发者ID:Jopperi,项目名称:wiki,代码行数:10,代码来源:WikiPage.php

示例9: getKeyMods

 function getKeyMods($match = null, $select_name = 'exclude', $multiple = true, $count = true)
 {
     PHPWS_Core::initCoreClass('Key.php');
     $db = new PHPWS_DB('phpws_key');
     $db->addOrder('module asc');
     $result = $db->getObjects('Key');
     if ($result) {
         foreach ($result as $item) {
             if ($count) {
                 $db = new PHPWS_DB('phpws_key');
                 $db->addWhere('module', $item->module);
                 $qty = $db->count();
                 if ($qty == 1) {
                     $qty_label = dgettext('whatsnew', 'item');
                 } else {
                     $qty_label = dgettext('whatsnew', 'items');
                 }
                 $items[$item->module] = $item->module . ' (' . $qty . ' ' . $qty_label . ')';
             } else {
                 $items[$item->module] = $item->module;
             }
         }
     }
     if ($items) {
         if ($multiple) {
             $form = new PHPWS_Form();
             $form->addMultiple($select_name, $items);
             if (!empty($match) && is_array($match)) {
                 $form->setMatch($select_name, $match);
             }
             return $form->get($select_name);
         } else {
             $form = new PHPWS_Form();
             $form->addSelect($select_name, $items);
             if (!empty($match) && is_string($match)) {
                 $form->setMatch($select_name, $match);
             }
             return $form->get($select_name);
         }
     } else {
         return dgettext('whatsnew', 'No keyed items.');
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:43,代码来源:Whatsnew.php

示例10: getQueueCount

 /**
  * Returns the number of items in the Banner queue for this term
  * TODO: Move this to the BannerQueue class.
  * @return Integer The number of items in the banner queue.
  */
 public function getQueueCount()
 {
     $db = new PHPWS_DB('hms_banner_queue');
     $db->addWhere('term', $this->term);
     $result = $db->count();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->__toString());
     }
     return $result;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:15,代码来源:Term.php

示例11: countLotteryAssigned

 public static function countLotteryAssigned($term)
 {
     $db = new PHPWS_DB('hms_assignment');
     $db->addWhere('term', $term);
     $db->addWhere('reason', ASSIGN_LOTTERY);
     $count = $db->count();
     if (PHPWS_Error::isError($count)) {
         throw new DatabaseException($count->toString());
     }
     return $count;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:11,代码来源:LotteryProcess.php

示例12: getUnprintedCount

 public static function getUnprintedCount()
 {
     $db = new PHPWS_DB('faxmaster_fax');
     $db->addWhere('printed', 0);
     $db->addWhere('hidden', 0);
     $db->addWhere('archived', 0);
     // don't include archived faxes, even if they aren't printed
     return $db->count();
 }
开发者ID:sinkdb,项目名称:faxserv,代码行数:9,代码来源:Fax.php


注:本文中的PHPWS_DB::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。