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


PHP SelectQuery::addOrderBy方法代码示例

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


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

示例1: PersistentOrderedSet

 /**
  * Constructor.
  * @param object Id $setId The Id of this set.
  * @param integer $dbIndex The index of the database connection which has
  * 		tables in which to store the set.
  */
 function PersistentOrderedSet($setId, $dbIndex)
 {
     parent::OrderedSet($setId);
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // Create our internal array
     $this->_dbIndex = $dbIndex;
     // populate our array with any previously stored items.
     $query = new SelectQuery();
     $query->addColumn("item_order", "item_order");
     $query->addColumn("item_id", "item_id");
     $query->addTable("sets");
     $query->addWhere("id = '" . addslashes($this->_setId->getIdString()) . "'");
     $query->addOrderBy("item_order");
     $dbHandler = Services::getService("DatabaseManager");
     $result = $dbHandler->query($query, $this->_dbIndex);
     $i = 0;
     $oldItems = array();
     while ($result->hasMoreRows()) {
         // Add the items to our array
         $this->_items[$i] = $result->field("item_id");
         // Store an array of the order-key/value relationships to reference
         // when updating any inconsistancies in order numbering.
         $oldItems[$result->field("item_order")] = $result->field("item_id");
         $i++;
         $result->advanceRow();
     }
     $result->free();
     // Make sure that we have our set is filled from 0 to count()
     reset($oldItems);
     $this->_updateOrders($oldItems);
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:37,代码来源:PersistentOrderedSet.class.php

示例2: isCurrent

 /**
  * Answer true if this version is the current version.
  *
  * @return boolean
  * @access public
  * @since 1/8/08
  */
 public function isCurrent()
 {
     $query = new SelectQuery();
     $query->addTable('segue_plugin_version');
     $query->addColumn('version_id');
     $query->addWhereEqual('node_id', $this->pluginInstance->getId());
     $query->addOrderBy('tstamp', SORT_DESC);
     $query->limitNumberOfRows(1);
     $dbc = Services::getService('DBHandler');
     $result = $dbc->query($query, IMPORTER_CONNECTION);
     if ($result->field('version_id') == $this->getVersionId()) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:adamfranco,项目名称:segue,代码行数:23,代码来源:SeguePluginVersion.class.php

示例3: getTableList

 /**
  * Returns a list of the tables that exist in the currently connected database.
  * @return array
  * @access public
  */
 function getTableList()
 {
     $query = new SelectQuery();
     $query->addTable("pg_stat_user_tables");
     $query->addColumn("relname");
     $query->addOrderBy("relname", ASCENDING);
     $res = $this->query($query);
     $list = array();
     while ($res->hasMoreRows()) {
         $list[] = $res->field(0);
         $res->advanceRow();
     }
     $res->free();
     return $list;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:20,代码来源:PostgreSQLDatabase.class.php

示例4: getAgentIds

 /**
  * Answer agentIds that have stored tags
  * 
  * @return object IdIterator
  * @access public
  * @since 11/1/06
  */
 function getAgentIds()
 {
     $query = new SelectQuery();
     $query->addColumn('user_id');
     $query->addColumn('COUNT(user_id)', 'occurances');
     $query->addTable('tag');
     $query->setGroupBy(array('user_id'));
     $query->addOrderBy('occurances', DESCENDING);
     $dbc = Services::getService("DatabaseManager");
     $result = $dbc->query($query, $this->getDatabaseIndex());
     // Add tag objects to an array, still sorted by frequency of usage
     $agentIds = array();
     $idManager = Services::getService('Id');
     while ($result->hasNext()) {
         $row = $result->next();
         $agentIds[] = $idManager->getId($row['user_id']);
     }
     $iterator = new HarmoniIterator($agentIds);
     return $iterator;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:27,代码来源:TagManager.class.php

示例5: SelectQuery

 /**
  * Traverses up and caches whatever needs to be cached.
  * @access public
  * @param string idValue The string id of the node to start traversal from.
  * @param integer levels Specifies how many levels of nodes to traverse. If this is negative
  * then the traversal will go on until the last level is processed.
  * @return void
  **/
 function _traverseUp($idValue, $levels)
 {
     $dbHandler = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     // the original value of levels
     $originalLevels = $levels;
     // 		echo "<br /><br /><br /><b>=== TraverseUp: Caching node # $idValue, $levels levels up</b><br />";
     // MySQL has a limit of 31 tables in a select query, thus essentially
     // there is a limit to the max value of $levels.
     // if levels > 31 or levels is negative (full traversal)
     // then set it to 31
     if ($levels > 31 || $levels < 0) {
         $levels = 31;
     }
     // generate query
     $query->addColumn("fk_child", "level0_id", "level0");
     $query->addColumn("fk_parent", "level1_id", "level0");
     $query->addTable("az2_j_node_node", NO_JOIN, "", "level0");
     $query->addOrderBy("level0_id");
     $query->addOrderBy("level1_id");
     // now left join with itself.
     // maximum number of joins is 31, we've used 1 already, so there are 30 left
     for ($level = 1; $level <= $levels - 1; $level++) {
         $joinc = "level" . ($level - 1) . ".fk_hierarchy = level" . $level . ".fk_hierarchy AND level" . ($level - 1) . ".fk_parent = level" . $level . ".fk_child";
         $query->addTable("az2_j_node_node", LEFT_JOIN, $joinc, "level" . $level);
         $query->addColumn("fk_parent", "level" . ($level + 1) . "_id", "level" . $level);
         $query->addOrderBy("level" . ($level + 1) . "_id");
     }
     // this is the where clause
     $where = "level0.fk_hierarchy = '" . addslashes($this->_hierarchyId) . "' AND level0.fk_child = '" . addslashes($idValue) . "'";
     $query->addWhere($where);
     //		echo "<pre>\n";
     //		echo MySQL_SQLGenerator::generateSQLQuery($query);
     //		echo "</pre>\n";
     // execute the query
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     if ($queryResult->hasNext() == 0) {
         $queryResult->free();
         return;
     }
     // note that the query only returns ids of nodes; thus, for each id,
     // we would need to fetch the actual node information from the node table.
     // for all rows returned by the query
     while ($queryResult->hasMoreRows()) {
         $row = $queryResult->getCurrentRow();
         // check all non-null values in current row
         // see if it is cached, if not create a group object and cache it
         for ($level = 0; $level <= $levels; $level++) {
             $nodeId = $row["level{$level}_id"];
             // ignore null values
             if (is_null($nodeId)) {
                 // 					echo "<br />--- skipping to next row (null value encountered)<br />";
                 break;
             }
             // 				echo "<br /><b>Level: $level - Node # $nodeId</b>";
             // if the node has not been cached, then we must create it
             // 				echo "<br />--- CACHE UPDATE: ";
             if (!$this->_isCached($nodeId)) {
                 $nodes = $this->getNodesFromDB($nodeId);
                 // must be only one node
                 if (count($nodes) != 1) {
                     throw new OperationFailedException(count($nodes) . " nodes found. Expecting 1.");
                 }
                 $displayName = $nodes[0]->getDisplayName();
                 // 					echo "Creating node # <b>$nodeId - '$displayName'</b>, ";
                 // insert node into cache
                 $this->_cache[$nodeId][0] = $nodes[0];
                 $this->_cache[$nodeId][1] = 0;
                 $this->_cache[$nodeId][2] = 0;
             }
             // 				else
             // 					echo "Node already in cache, ";
             // update the levels fetched up, if necessary
             $old = $this->_cache[$nodeId][2];
             // 				print " old=$old levels=$levels level=$level, ";
             if ($old >= 0 && $old < $levels - $level) {
                 if ($originalLevels < 0) {
                     // if fully, then the node is fetched fully as well
                     $this->_cache[$nodeId][2] = -1;
                 } else {
                     // if not fully, then set the value appropriately
                     $this->_cache[$nodeId][2] = $levels - $level;
                 }
                 // 					echo "changing level of caching from <b>$old</b> to <b>".$this->_cache[$nodeId][2]."</b>";
             }
             // 				else
             // 					echo "no need to set level of caching";
             // now, update tree structure
             // 				echo "<br />--- TREE STRUCTURE UPDATE: ";
             // get the current node (create it, if necessary)
             if ($this->_tree->nodeExists($nodeId)) {
                 $node = $this->_tree->getNode($nodeId);
//.........这里部分代码省略.........
开发者ID:adamfranco,项目名称:harmoni,代码行数:101,代码来源:HierarchyCache.class.php

示例6: getAllPropertyKeys

 /**
  * Answer an array of all of the property keys inexistance
  * 
  * @return array
  * @access public
  * @since 11/1/05
  */
 function getAllPropertyKeys()
 {
     $propertyKeys = array();
     $dbHandler = Services::getService("DBHandler");
     //select the propertykeys
     $query = new SelectQuery();
     $query->addTable("agent_properties");
     $query->addColumn("DISTINCT property_key");
     // 		$query->addTable("type", LEFT_JOIN, "agent_properties.fk_type_id=type.type_id");
     // 		$query->addColumn("property_key");
     // 		$query->addColumn("type_domain");
     // 		$query->addColumn("type_authority");
     // 		$query->addColumn("type_keyword");
     // 		$query->addColumn("type_description");
     $query->addOrderBy("property_key");
     $result = $dbHandler->query($query, $this->_dbIndex);
     while ($result->hasMoreRows()) {
         $propertyKeys[] = $result->field('property_key');
         // 			$propertyKeys[$result->field('property_key')] = new Type(
         // 				$result->field('type_domain'),
         // 				$result->field('type_authority'),
         // 				$result->field('type_keyword'),
         // 				$result->field('type_description'));
         $result->advanceRow();
     }
     $result->free();
     return $propertyKeys;
     //return the properties
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:36,代码来源:HarmoniPropertyManager.class.php

示例7: getAvailableTimes

 /**
  * Get the Timespans during which all Agents are uncommitted.
  * The time complexity may not be great on this one.
  *
  * @param object Id[] $agents
  * @param int $start
  * @param int $end
  *
  * @return object TimespanIterator
  *
  * @throws object SchedulingException An exception with one of
  *         the following messages defined in
  *         org.osid.scheduling.SchedulingException may be thrown:   {@link
  *         org.osid.scheduling.SchedulingException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.scheduling.SchedulingException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.scheduling.SchedulingException#UNKNOWN_ID UNKNOWN_ID},
  *         {@link org.osid.scheduling.SchedulingException#END_BEFORE_START
  *         END_BEFORE_START}
  *
  * @access public
  */
 function getAvailableTimes(array $agents, $start, $end)
 {
     if (count($agents) == 0) {
         $array[] = new HarmoniTimespan($start, $end);
         $ret = new HarmoniTimespanIterator($array);
         return $ret;
     }
     //get all schedule item rows with the appropriate time and agents
     $dbHandler = Services::getService("DBHandler");
     $query = new SelectQuery();
     $query->addTable('sc_item');
     $query->addTable('sc_commit', INNER_JOIN, "sc_item.id=sc_commit.fk_sc_item");
     $query->addColumn('sc_item.id');
     $where = "(end_date >= '" . addslashes($start) . "'";
     $where .= " OR start_date <= '" . addslashes($end) . "') AND (";
     $firstElement = true;
     foreach ($agents as $agentId) {
         if (!$firstElement) {
             $where .= " OR ";
         } else {
             $firstElement = false;
         }
         $where .= "sc_commit.fk_agent_id='" . addslashes($agentId->getIdString()) . "'";
     }
     $where .= ")";
     $query->addOrderBy('sc_item.id');
     $query->addWhere($where);
     $res = $dbHandler->query($query);
     //find times not conflicted by these items
     //yes I know $mister11 is a terible name for the variable.  Deal with it :-P.
     //We'll
     $availableTimes = array();
     $availableTimes[$start] = new HarmoniTimeSpan($start, $end);
     //print_r($thearray);
     $idManager = Services::getService("IdManager");
     $lastId = "";
     while ($res->hasMoreRows()) {
         $row = $res->getCurrentRow();
         $res->advanceRow();
         $idString = $row['id'];
         if ($lastId != $idString) {
             $id = $idManager->getId($idString);
             $item = $this->getScheduleItem($id);
             $availableTimes = $this->_restrict($item, $availableTimes);
             $lastId = $idString;
         }
     }
     //print_r($thearray);
     //ksort($thearray);
     $ret = new HarmoniTimespanIterator($availableTimes);
     return $ret;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:81,代码来源:HarmoniSchedulingManager.class.php

示例8: SelectQuery

 function _loadPlugins()
 {
     // cache the installed plugins
     $db = Services::getService("DBHandler");
     $pm = Services::getService("Plugs");
     $query = new SelectQuery();
     $query->addTable("plugin_type");
     $query->addColumn("*");
     $query->addOrderBy('type_id');
     $results = $db->query($query, IMPORTER_CONNECTION);
     $dis = array();
     $en = array();
     while ($results->hasNext()) {
         $result = $results->next();
         $pluginType = new Type($result['type_domain'], $result['type_authority'], $result['type_keyword']);
         $class = $this->getPluginClass($pluginType);
         if (class_exists($class)) {
             $pluginType = new Type($pluginType->getDomain(), $pluginType->getAuthority(), $pluginType->getKeyword(), call_user_func(array($class, 'getPluginDescription')));
         }
         if ($result['type_enabled'] == 1) {
             $this->_enabledPlugins[HarmoniType::typeToString($pluginType)] = $pluginType;
         } else {
             $this->_disabledPlugins[HarmoniType::typeToString($pluginType)] = $pluginType;
         }
     }
     $this->_cachePluginArrays();
 }
开发者ID:adamfranco,项目名称:segue,代码行数:27,代码来源:PluginManager.class.php

示例9: buildContent

 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $dbHandler = Services::getService("DBHandler");
     $rm = Services::getService("Repository");
     $agentM = Services::getService("Agent");
     $idManager = Services::getService("Id");
     print "lines 46 - 49 in authtrans.act.php need to be modified for database access";
     //		$mdbIndex = $dbHandler->addDatabase(
     //			new MySQLDatabase("host", "db", "uname", "password"));
     //		$dbHandler->connect($mdbIndex);
     exit;
     $searchTypes = $agentM->getAgentSearchTypes();
     $searchType = $searchTypes->next();
     $centerPane = $this->getActionRows();
     ob_start();
     $unamesQuery = new SelectQuery();
     $unamesQuery->addTable("users");
     $unamesQuery->addColumn("uname");
     $unamesQuery->addColumn("email");
     $unamesQuery->addOrderBy("uname");
     $unamesResults = $dbHandler->query($unamesQuery, $mdbIndex);
     $unameToId = array();
     // key on mdb uname value to c_beta id
     while ($unamesResults->hasMoreRows()) {
         $unamePair = $unamesResults->next();
         if (!is_null($unamePair['email'])) {
             $agents = $agentM->getAgentsBySearch($unamePair['email'], $searchType);
             if ($agents->hasNext()) {
                 $agent = $agents->next();
             }
             $unameToId[$unamePair['uname']] = $agent->getId();
         }
     }
     // ===== at this point we have unames and ids
     $mediasetsQuery = new SelectQuery();
     $mediasetsQuery->addTable("mediasets");
     $mediasetsQuery->addColumn("title");
     $mediasetsQuery->addColumn("editors");
     $mediasetsQuery->addColumn("presenters");
     $mediasetsQuery->addColumn("search");
     $mediasetsQuery->addOrderBy("title");
     $mediasetsResults = $dbHandler->query($mediasetsQuery, $mdbIndex);
     $repositories = $rm->getRepositories();
     $reps = array();
     while ($repositories->hasNext()) {
         $rep = $repositories->next();
         $reps[$rep->getDisplayName()] = array('id' => $rep->getId());
     }
     unset($reps['All Exhibitions']);
     // ===== at this point we have repository id's associated with displaynames
     while ($mediasetsResults->hasMoreRows()) {
         $mediasetInfo = $mediasetsResults->next();
         if (isset($reps[$mediasetInfo['title']])) {
             $editors = unserialize($mediasetInfo['editors']);
             $presenters = unserialize($mediasetInfo['presenters']);
             if (count($editors) > 0) {
                 $reps[$mediasetInfo['title']]['editors'] = array();
             }
             foreach ($editors as $editor) {
                 if (isset($unameToId[trim($editor)])) {
                     $reps[$mediasetInfo['title']]['editors'][] = $unameToId[trim($editor)];
                 }
             }
             if (count($presenters) > 0) {
                 $reps[$mediasetInfo['title']]['presenters'] = array();
             }
             foreach ($presenters as $presenter) {
                 if (isset($unameToId[trim($presenter)])) {
                     $reps[$mediasetInfo['title']]['presenters'][] = $unameToId[trim($presenter)];
                 }
             }
             switch ($mediasetInfo['search']) {
                 case '1':
                     $reps[$mediasetInfo['title']]['search'] = 'edu.middlebury.agents.everyone';
                     break;
                 case '2':
                     $reps[$mediasetInfo['title']]['search'] = 'edu.middlebury.agents.users';
                     break;
                 case '3':
                     $reps[$mediasetInfo['title']]['search'] = 'CN=All Faculty,OU=General,OU=Groups,DC=middlebury,DC=edu';
                     break;
                 default:
                     break;
             }
         }
     }
     // ===== at this point reps has presenters and editors for each mediaset
     $pressetsQuery = new SelectQuery();
     $pressetsQuery->addTable("pressets");
     $pressetsQuery->addColumn("title");
     $pressetsQuery->addColumn("presenters");
     $pressetsQuery->addColumn("owner");
     $pressetsQuery->addColumn("view");
//.........这里部分代码省略.........
开发者ID:adamfranco,项目名称:concerto,代码行数:101,代码来源:authtrans.act.php

示例10: array

 /**
  * Load the authoritative value list
  *
  * WARNING: NOT in OSID
  * 
  * @return void
  * @access private
  * @since 4/25/06
  */
 function _loadAuthoritativeValueStrings()
 {
     if (!isset($this->_authoritativeValueStrings)) {
         $this->_authoritativeValueStrings = array();
         $query = new SelectQuery();
         $query->addTable('dr_authoritative_values');
         $query->addColumn('value');
         $id = $this->getId();
         $query->addWhere("fk_partstructure = '" . addslashes($id->getIdString()) . "'");
         $query->addWhere("fk_repository = '" . addslashes($this->_repositoryId->getIdString()) . "'");
         $query->addOrderBy("value", ASCENDING);
         $dbc = Services::getService("DBHandler");
         $configuration = $this->manager->_configuration;
         $result = $dbc->query($query, $configuration->getProperty('database_index'));
         while ($result->hasMoreRows()) {
             $this->_authoritativeValueStrings[] = $result->field('value');
             $result->advanceRow();
         }
         $result->free();
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:30,代码来源:HarmoniPartStructure.class.php

示例11: loadNextBatch

 /**
  * Load the next batch of slots
  * 
  * @return void
  * @access private
  * @since 12/4/07
  */
 private function loadNextBatch()
 {
     $query = new SelectQuery();
     $query->addColumn('shortname');
     $query->addTable('segue_slot');
     $query->startFromRow($this->startingNumber + 1);
     $query->limitNumberOfRows(50);
     $query->addOrderBy('shortname');
     // 		printpre($query->asString());
     $dbc = Services::getService('DBHandler');
     $result = $dbc->query($query, IMPORTER_CONNECTION);
     $slotNames = array();
     while ($result->hasNext()) {
         $slotNames[] = $result->field('shortname');
         $result->next();
         $this->startingNumber++;
     }
     // 		printpre($slotNames);
     $slotMgr = SlotManager::instance();
     $slots = $slotMgr->loadSlotsFromDb($slotNames);
     foreach ($slots as $slot) {
         $this->queue[] = $slot;
     }
 }
开发者ID:adamfranco,项目名称:segue,代码行数:31,代码来源:AllSlotsIterator.class.php

示例12: execute

 /**
  * Execute
  * 
  * @return void
  * @access public
  * @since 3/26/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException('This command can only be run by admins or from the command-line.');
     }
     header("Content-Type: text/plain");
     if (RequestContext::value('help') || RequestContext::value('h') || RequestContext::value('?')) {
         throw new HelpRequestedException($this->usage);
     }
     $outDir = RequestContext::value('d');
     if (empty($outDir)) {
         throw new InvalidArgumentException("An output directory must be specified.\n\n" . $this->usage);
     }
     if (!is_dir($outDir) || !is_writable($outDir)) {
         throw new InvalidArgumentException("The output directory doesn't exist or is not writeable.\n\n" . $this->usage);
     }
     foreach (SlotAbstract::getLocationCategories() as $category) {
         $baseUrl = SiteDispatcher::getBaseUrlForLocationCategory($category);
         if (!preg_match('/^https?:\\/\\/.+/', $baseUrl)) {
             throw new ConfigurationErrorException('Please set a base URL for the \'' . $category . '\' category with SiteDispatcher::setBaseUrlForLocationCategory($category, $url); in config/slots.conf.php');
         }
     }
     while (ob_get_level()) {
         ob_end_flush();
     }
     flush();
     /*********************************************************
      * Check for a running export
      *********************************************************/
     $dbc = Services::getService('DatabaseManager');
     $query = new SelectQuery();
     $query->addColumn('slot');
     $query->addColumn('pid');
     $query->addTable('site_export_queue');
     $query->addWhereNotEqual('pid', 0);
     $result = $dbc->query($query);
     // If we are exporting, check the status of the export process
     if ($result->hasMoreRows()) {
         // Don't start a new export if one is running.
         if ($this->isRunning($result->field('pid'))) {
             print "An export is already running\n";
             exit;
         } else {
             $query = new UpdateQuery();
             $query->setTable('site_export_queue');
             $query->addValue('status', 'DIED');
             $query->addRawValue('pid', 'NULL');
             $query->addValue('info', 'Process ' . $result->field('pid') . ' has died.');
             $query->addWhereEqual('slot', $result->field('slot'));
             $query->addWhereEqual('pid', $result->field('pid'));
             $dbc->query($query);
         }
     }
     /*********************************************************
      * If there aren't any other exports happening, run our export
      *********************************************************/
     // Find the next slot to update
     $query = new SelectQuery();
     $query->addColumn('slot');
     $query->addTable('site_export_queue', NO_JOIN, '', 'q');
     $query->addTable('segue_slot', INNER_JOIN, 'q.slot = s.shortname', 's');
     $query->addWhereNull('pid');
     $query->addWhereNull('status');
     $query->addWhereNull('alias_target');
     $query->addWhereNotEqual('site_id', '');
     $query->addOrderBy('priority', DESCENDING);
     $query->addOrderBy('slot', ASCENDING);
     $result = $dbc->query($query);
     // Exit if there is nothing to do.
     if (!$result->hasMoreRows()) {
         print "The queue is empty\n";
         exit;
     }
     $slot = $result->field('slot');
     $slotMgr = SlotManager::instance();
     $slotObj = $slotMgr->getSlotByShortname($slot);
     $baseUrl = SiteDispatcher::getBaseUrlForLocationCategory($slotObj->getLocationCategory());
     // Mark that we are running
     $query = new UpdateQuery();
     $query->setTable('site_export_queue');
     $query->addValue('pid', strval(getmypid()));
     $query->addWhereEqual('slot', $slot);
     $dbc->query($query);
     // Run the export
     $start = microtime(true);
     try {
         $exportDirname = $slot . "-html";
         $exportDir = $outDir . "/" . $exportDirname;
         $archivePath = $outDir . '/' . $exportDirname . ".zip";
         if (file_exists($exportDir)) {
             $this->deleteRecursive($exportDir);
         }
         mkdir($exportDir);
//.........这里部分代码省略.........
开发者ID:adamfranco,项目名称:segue,代码行数:101,代码来源:check_export_queue.act.php

示例13: getRosterByType

 /**
  * Get the student roster.	Include only students with the specified
  * Enrollment Status Type.  This returns all the enrollments of all the course 
  * sections.  Keep in mind that they will be ordered by the students that are in
  * section.  Each student may be enrolled in several CoursesSctions.
  *
  * @param object Type $enrollmentStatusType
  *
  * @return object EnrollmentRecordIterator
  *
  * @throws object CourseManagementException An exception
  *		   with one of the following messages defined in
  *		   org.osid.coursemanagement.CourseManagementException may be
  *		   thrown:	{@link
  *		   org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  *		   UNKNOWN_TYPE}
  *
  * @access public
  */
 function getRosterByType(Type $enrollmentStatusType)
 {
     $idManager = Services::getService('IdManager');
     $dbManager = Services::getService("DatabaseManager");
     $courseSectionIterator = $this->getCourseSections();
     //quit out if there is not any CourseSection
     $array = array();
     if (!$courseSectionIterator->hasNextCourseSection()) {
         $ret = new HarmoniEnrollmentRecordIterator($array);
         return $ret;
     }
     //set up a query
     $query = new SelectQuery();
     $query->addTable('cm_enroll');
     $query->addColumn('id');
     //set up a where
     $where = "(";
     $first = true;
     //add necesary or's
     while ($courseSectionIterator->hasNextCourseSection()) {
         if (!$first) {
             $where .= " OR ";
         }
         $first = false;
         $section = $courseSectionIterator->nextCourseSection();
         $sectionId = $section->getId();
         $where .= "fk_cm_section='" . addslashes($sectionId->getIdString()) . "'";
     }
     //finish query
     $typeIndex = $this->_typeToIndex('enroll_stat', $enrollmentStatusType);
     $query->addWhere($where . ") AND fk_cm_enroll_stat_type='" . addslashes($typeIndex) . "'");
     $query->addOrderBy('id');
     $res = $dbManager->query($query);
     //add all EnrollmentRecords to an array
     while ($res->hasMoreRows()) {
         $row = $res->getCurrentRow();
         $res->advanceRow();
         $array[] = new HarmoniEnrollmentRecord($idManager->getId($row['id']));
     }
     //return them as an iterator
     $ret = new HarmoniEnrollmentRecordIterator($array);
     return $ret;
     //oldcode
     /*
     
     
     		$idManager = Services::getService('IdManager');
     		$dbManager = Services::getService("DatabaseManager");
     
     		$query= new SelectQuery;
     		$query->addTable('cm_enroll');
     		$query->addColumn('id');
     		$typeIndex = $this->_typeToIndex('enroll_stat',$enrollmentStatusType);
     
     		$courseSectionIterator = $this->getCourseSections();
     
     		while($courseSectionIterator->hasNextCourseSection()){
     			$section = $courseSectionIterator->nextCourseSection();
     			$sectionId = $section->getId();			
     			$query->addWhere("fk_cm_section='".addslashes($sectionId->getIdString())."' AND fk_cm_enroll_stat_type='".addslashes($typeIndex)."'");
     		}
     		$query->addOrderBy('id');
     $res=$dbManager->query($query);
     
     		$array=array();
     		while($res->hasMoreRows()){
     				$row = $res->getCurrentRow();
     				$res->advanceRow();
     				
     				$array[] = new HarmoniEnrollmentRecord($idManager->getId($row['id']));
     			}
//.........这里部分代码省略.........
开发者ID:adamfranco,项目名称:harmoni,代码行数:101,代码来源:CourseOffering.class.php

示例14: getAssetsBySearch

 /**
  * Perform a search of the specified Type and get all the Assets that
  * satisfy the SearchCriteria.  Iterators return a set, one at a time.
  * 
  * @param object mixed $searchCriteria (original type: java.io.Serializable)
  * @param object Type $searchType
  * @param object Properties $searchProperties
  *  
  * @return object AssetIterator
  * 
  * @throws object RepositoryException An exception with one of
  *         the following messages defined in
  *         org.osid.repository.RepositoryException may be thrown: {@link
  *         org.osid.repository.RepositoryException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.repository.RepositoryException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.repository.RepositoryException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.repository.RepositoryException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.repository.RepositoryException#UNKNOWN_TYPE
  *         UNKNOWN_TYPE}
  * 
  * @access public
  */
 function getAssetsBySearch($searchCriteria, Type $searchType, Properties $searchProperties)
 {
     if ($searchType->isEqual(new Type("Repository", "edu.middlebury.harmoni", "Keyword", "Search with a string for keywords."))) {
         if (!is_string($searchCriteria)) {
             throw new OperationFailedException('search criteria should be a string.');
         }
         // Convert the criteria to the proper character set.
         $encoding = $this->config['encoding'];
         if (!is_null($encoding)) {
             $searchCriteria = iconv('UTF-8', $encoding, $searchCriteria);
         }
         $query = new SelectQuery();
         $query->addTable($this->config['table']);
         $query->addColumn($this->config['id_column']);
         $query->addWhereLike($this->config['id_column'], '%' . $searchCriteria . '%');
         foreach ($this->config['columns'] as $column) {
             $query->addColumn($column);
             $query->addWhereLike($column, '%' . $searchCriteria . '%', _OR);
         }
         if ($this->config['order_column']) {
             $query->addOrderBy($this->config['order_column'], $this->config['order_direction']);
         }
         return new SimpleTableAssetIterator($this, $this->config, $this->dbc->query($query, $this->dbIndex));
     } else {
         if ($searchType->isEqual(new Type("Repository", "edu.middlebury.harmoni", "RootAssets", "Search for just the 'root' or 'top level' assets which are not assets of other assets."))) {
             return $this->getAssets();
         } else {
             throw new UnknownTypeException('UNKNOWN_TYPE');
         }
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:59,代码来源:SimpleTableRepository.class.php

示例15: getAZs


//.........这里部分代码省略.........
     }
     $allAgentIds = array_merge($agentIds, $groupIds);
     // the agent criteria
     if (count($allAgentIds)) {
         $query->addWhereIn('az_authorization.fk_agent', $allAgentIds);
     }
     // the function criteria
     if (isset($fId)) {
         $joinc = "az_authorization.fk_function = az_function.function_id";
         $query->addTable("az_function", INNER_JOIN, $joinc);
         $query->addWhereEqual("az_authorization.fk_function", $fId);
     }
     // the function type criteria
     if (isset($fType)) {
         // do not join with az_function if we did already
         if (!isset($fId)) {
             $joinc = "az_authorization.fk_function = az_function.function_id";
             $query->addTable("az_function", INNER_JOIN, $joinc);
         }
         // now join with type
         $joinc = "az_function.fk_type = type.type_id";
         $query->addTable("type", INNER_JOIN, $joinc);
         $query->addWhereEqual("type.type_domain", $fType->getDomain());
         $query->addWhereEqual("type.type_authority", $fType->getAuthority());
         $query->addWhereEqual("type.type_keyword", $fType->getKeyword());
     }
     // the isActiveNow criteria
     if ($isActiveNow) {
         $where = "(authorization_effective_date IS NULL OR (NOW() >= authorization_effective_date))";
         $query->addWhere($where);
         $where = "(authorization_expiration_date IS NULL OR (NOW() < authorization_expiration_date))";
         $query->addWhere($where);
     }
     $query->addOrderBy("authorization_id");
     //		echo "<pre>\n";
     //		echo MySQL_SQLGenerator::generateSQLQuery($query);
     //		echo "</pre>\n";
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     // this array will store the authorizations that will be returned
     $authorizations = array();
     // we only want to create one implicitAZ for a given Agent/Function/Qualifier
     // combo, so maintain a list of already created ones to skip
     $createdImplicitAZs = array();
     $i = 0;
     // process all rows and create the explicit authorizations
     while ($queryResult->hasMoreRows()) {
         $row = $queryResult->getCurrentRow();
         // 			printpre($row);
         $idValue = $row['id'];
         $id = $idManager->getId($idValue);
         if (isset($this->_authorizations[$idValue])) {
             $authorization = $this->_authorizations[$idValue];
         } else {
             $agentId = $idManager->getId($row['aid']);
             $functionId = $idManager->getId($row['fid']);
             $explicitQualifierId = $idManager->getId($row['qid']);
             $effectiveDate = $dbHandler->fromDBDate($row['eff_date'], $this->_dbIndex);
             $expirationDate = $dbHandler->fromDBDate($row['exp_date'], $this->_dbIndex);
             // create the explicit authorization (each explicit authorization
             // has a corresponding row in the authorization db table)
             $authorization = new HarmoniAuthorization($idValue, $agentId, $functionId, $explicitQualifierId, true, $this, $effectiveDate, $expirationDate);
             $this->_authorizations[$idValue] = $authorization;
         }
         // Explicit AZ for ancestor qualifiers and groups should have
         // corresponding implicit AZs
         // in decendents, but not appear in their AZs directly.
开发者ID:adamfranco,项目名称:harmoni,代码行数:67,代码来源:AuthorizationCache.class.php


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