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


PHP SelectQuery::limitNumberOfRows方法代码示例

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


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

示例1: getTagsForItemsNotByAgent

 /**
  * Answer the tags not created by the given agent for one or more items
  * 
  * @param mixed $items The items to return tags for. This can be a single Item object,
  *		an ItemIterator, or an array of Item objects.
  * @param object Id $agentId
  * @param string $sortBy Return tags in alphanumeric order or by frequency of usage.
  * @param integer $max The maximum number of tags to return. The least frequently used
  * 		tags will be dropped first. If $max is 0, all tags will be returned.
  * @return object TagIterator
  * @access public
  * @since 11/10/06
  */
 function getTagsForItemsNotByAgent($items, $agentId, $sortBy = TAG_SORT_ALFA, $max = 0)
 {
     $query = new SelectQuery();
     $query->addColumn('value');
     $query->addColumn('COUNT(value)', 'occurances');
     $query->addTable('tag');
     $query->setGroupBy(array('value'));
     $query->addOrderBy('occurances', DESCENDING);
     $query->addWhere("user_id!='" . addslashes($agentId->getIdString()) . "'");
     if ($max) {
         $query->limitNumberOfRows($max);
     }
     $itemDbIds = array();
     // array
     if (is_array($items)) {
         foreach (array_keys($items) as $key) {
             $itemDbIds[] = "'" . addslashes($items[$key]->getDatabaseId()) . "'";
         }
     } else {
         if (method_exists($items, 'next')) {
             while ($items->hasNext()) {
                 $item = $items->next();
                 $itemDbIds[] = "'" . addslashes($item->getDatabaseId()) . "'";
             }
         } else {
             if (method_exists($items, 'getDatabaseId')) {
                 $itemDbIds[] = "'" . addslashes($items->getDatabaseId()) . "'";
             } else {
                 throwError(new Error("Invalid parameter, " . get_class($items) . ", for \$items", "Tagging"));
             }
         }
     }
     $query->addWhere("tag.fk_item IN (" . implode(", ", $itemDbIds) . ")");
     $dbc = Services::getService("DatabaseManager");
     $result = $dbc->query($query, $this->getDatabaseIndex());
     // Add tag objects to an array, still sorted by frequency of usage
     $tags = array();
     while ($result->hasNext()) {
         $row = $result->next();
         $tags[$row['value']] = new Tag($row['value']);
         $tags[$row['value']]->setOccurances($row['occurances']);
     }
     // If necessary, sort these top tags alphabetically
     if ($sortBy == TAG_SORT_ALFA) {
         ksort($tags);
     }
     $iterator = new HarmoniIterator($tags);
     return $iterator;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:62,代码来源:TagManager.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: getRecentSlots

 /**
  * Answer a list of most recently seen slot-names ordered recent-first.
  * 
  * @return array
  * @access public
  * @since 9/22/08
  */
 public function getRecentSlots()
 {
     $slots = array();
     $dbc = Services::getService('DatabaseManager');
     $query = new SelectQuery();
     $query->addTable('segue_accesslog');
     $query->addColumn('fk_slotname');
     $query->addColumn('tstamp');
     $query->addWhereEqual('agent_id', $this->_getCurrentAgentId());
     $query->addOrderBy('tstamp', DESCENDING);
     $query->limitNumberOfRows(50);
     $result = $dbc->query($query, IMPORTER_CONNECTION);
     while ($result->hasNext()) {
         $row = $result->next();
         $slots[$row['fk_slotname']] = DateAndTime::fromString($row['tstamp'])->asString();
     }
     // Add session-stored slots
     if (isset($_SESSION['segue_access_log'])) {
         foreach ($_SESSION['segue_access_log'] as $slotname => $tstamp) {
             $slots[$slotname] = $tstamp;
         }
         arsort($slots);
     }
     return array_keys($slots);
 }
开发者ID:adamfranco,项目名称:segue,代码行数:32,代码来源:AccessLog.class.php

示例4: assignConfiguration

 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     $dbName = $configuration->getProperty('database_name');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     ArgumentValidator::validate($dbName, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbIndex = $dbIndex;
     // Store the Harmoni_Db adapter if it is configured.
     $harmoni_db_name = $this->_configuration->getProperty('harmoni_db_name');
     if (!is_null($harmoni_db_name)) {
         try {
             $this->harmoni_db = Harmoni_Db::getDatabase($harmoni_db_name);
         } catch (UnknownIdException $e) {
         }
     }
     // do a test to see if our configuration worked.
     try {
         $dbHandler = Services::getService("DatabaseManager");
         $query = new SelectQuery();
         $query->addColumn("id");
         $query->addTable("az2_hierarchy");
         $query->limitNumberOfRows(1);
         $queryResult = $dbHandler->query($query, $this->_dbIndex);
     } catch (QueryDatabaseException $e) {
         throw new ConfigurationErrorException("Database is not properly set up for AuthZ2.");
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:50,代码来源:HierarchyManager.class.php

示例5: 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


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