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


PHP SMWQuery::getOffset方法代码示例

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


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

示例1: toArray

 /**
  * Returns a serialized SMWQueryResult object with additional meta data
  *
  * This methods extends the serializeToArray() for additional meta
  * that are useful when handling data via the api
  *
  * @note should be used instead of SMWQueryResult::serializeToArray()
  * as this method contains additional informaion
  *
  * @since 1.9
  *
  * @return array
  */
 public function toArray()
 {
     // @note micro optimization: We call getSerializedQueryResult()
     // only once and create the hash here instead of calling getHash()
     // to avoid getSerializedQueryResult() being called again
     // @note count + offset equals total therefore we deploy both values
     $serializeArray = $this->serializeToArray();
     return array_merge($serializeArray, array('meta' => array('hash' => md5(FormatJson::encode($serializeArray)), 'count' => $this->getCount(), 'offset' => $this->mQuery->getOffset())));
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:22,代码来源:SMW_QueryResult.php

示例2: toArray

 /**
  * Returns a serialized SMWQueryResult object with additional meta data
  *
  * This methods extends the serializeToArray() for additional meta
  * that are useful when handling data via the api
  *
  * @note should be used instead of SMWQueryResult::serializeToArray()
  * as this method contains additional informaion
  *
  * @since 1.9
  *
  * @return array
  */
 public function toArray()
 {
     $time = microtime(true);
     // @note micro optimization: We call getSerializedQueryResult()
     // only once and create the hash here instead of calling getHash()
     // to avoid getSerializedQueryResult() being called again
     // @note count + offset equals total therefore we deploy both values
     $serializeArray = $this->serializeToArray();
     return array_merge($serializeArray, array('meta' => array('hash' => HashBuilder::createHashIdForContent($serializeArray), 'count' => $this->getCount(), 'offset' => $this->mQuery->getOffset(), 'source' => $this->mQuery->getQuerySource(), 'time' => number_format(microtime(true) - $time, 6, '.', ''))));
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:23,代码来源:SMW_QueryResult.php

示例3: get

 /**
  * @since 2.5
  *
  * @param Query $query
  *
  * @return string
  */
 public static function get(Query $query)
 {
     $serialized = array();
     $serialized['conditions'] = $query->getQueryString();
     $serialized['parameters'] = array('limit=' . $query->getLimit(), 'offset=' . $query->getOffset(), 'mainlabel=' . $query->getMainlabel());
     if ($query->getQuerySource() !== null && $query->getQuerySource() !== '') {
         $serialized['parameters'] = array_merge($serialized['parameters'], array('source=' . $query->getQuerySource()));
     }
     list($serialized['sort'], $serialized['order']) = self::doSerializeSortKeys($query);
     $serialized['printouts'] = self::doSerializePrintouts($query);
     $encoded = $serialized['conditions'] . '|' . ($serialized['printouts'] !== array() ? implode('|', $serialized['printouts']) . '|' : '') . implode('|', $serialized['parameters']) . ($serialized['sort'] !== array() ? '|sort=' . implode(',', $serialized['sort']) : '') . ($serialized['order'] !== array() ? '|order=' . implode(',', $serialized['order']) : '');
     return $encoded;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:20,代码来源:QueryStringifier.php

示例4: getQueryLink

 /**
  * Create an SMWInfolink object representing a link to further query results.
  * This link can then be serialised or extended by further params first.
  * The optional $caption can be used to set the caption of the link (though this
  * can also be changed afterwards with SMWInfolink::setCaption()). If empty, the
  * message 'smw_iq_moreresults' is used as a caption.
  * 
  * @deprecated since SMW 1.8
  *
  * @param string|false $caption
  * 
  * @return SMWInfolink
  */
 public function getQueryLink($caption = false)
 {
     $link = $this->getLink();
     if ($caption == false) {
         // The space is right here, not in the QPs!
         $caption = ' ' . wfMessage('smw_iq_moreresults')->inContentLanguage()->text();
     }
     $link->setCaption($caption);
     $params = array(trim($this->mQuery->getQueryString()));
     foreach ($this->mQuery->getExtraPrintouts() as $printout) {
         $serialization = $printout->getSerialisation();
         // TODO: this is a hack to get rid of the mainlabel param in case it was automatically added
         // by SMWQueryProcessor::addThisPrintout. Should be done nicer when this link creation gets redone.
         if ($serialization !== '?#') {
             $params[] = $serialization;
         }
     }
     if ($this->mQuery->getMainLabel() !== false) {
         $params['mainlabel'] = $this->mQuery->getMainLabel();
     }
     $params['offset'] = $this->mQuery->getOffset() + count($this->mResults);
     if ($params['offset'] === 0) {
         unset($params['offset']);
     }
     if ($this->mQuery->getLimit() > 0) {
         $params['limit'] = $this->mQuery->getLimit();
     }
     if (count($this->mQuery->sortkeys) > 0) {
         $order = implode(',', $this->mQuery->sortkeys);
         $sort = implode(',', array_keys($this->mQuery->sortkeys));
         if ($sort !== '' || $order != 'ASC') {
             $params['order'] = $order;
             $params['sort'] = $sort;
         }
     }
     foreach ($params as $key => $param) {
         $link->setParameter($param, is_string($key) ? $key : false);
     }
     return $link;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:53,代码来源:SMW_QueryResult.php

示例5: getQueryLink

 /**
  * Create an SMWInfolink object representing a link to further query results.
  * This link can then be serialised or extended by further params first.
  * The optional $caption can be used to set the caption of the link (though this
  * can also be changed afterwards with SMWInfolink::setCaption()). If empty, the
  * message 'smw_iq_moreresults' is used as a caption.
  * 
  * TODO: have this work for all params without manually overriding and adding everything
  * (this is possible since the param handling changes in 1.7) 
  * 
  * @param string|false $caption
  * 
  * @return SMWInfolink
  */
 public function getQueryLink($caption = false)
 {
     $params = array(trim($this->mQuery->getQueryString()));
     foreach ($this->mQuery->getExtraPrintouts() as $printout) {
         $serialization = $printout->getSerialisation();
         // TODO: this is a hack to get rid of the mainlabel param in case it was automatically added
         // by SMWQueryProcessor::addThisPrintout. Should be done nicer when this link creation gets redone.
         if ($serialization !== '?#') {
             $params[] = $serialization;
         }
     }
     if ($this->mQuery->getMainLabel() !== false) {
         $params['mainlabel'] = $this->mQuery->getMainLabel();
     }
     $params['offset'] = $this->mQuery->getOffset() + count($this->mResults);
     if ($params['offset'] === 0) {
         unset($params['offset']);
     }
     if ($this->mQuery->getLimit() > 0) {
         $params['limit'] = $this->mQuery->getLimit();
     }
     if (count($this->mQuery->sortkeys) > 0) {
         $order = implode(',', $this->mQuery->sortkeys);
         $sort = implode(',', array_keys($this->mQuery->sortkeys));
         if ($sort !== '' || $order != 'ASC') {
             $params['order'] = $order;
             $params['sort'] = $sort;
         }
     }
     if ($caption == false) {
         $caption = ' ' . wfMsgForContent('smw_iq_moreresults');
         // The space is right here, not in the QPs!
     }
     // Note: the initial : prevents SMW from reparsing :: in the query string.
     $result = SMWInfolink::newInternalLink($caption, ':Special:Ask', false, $params);
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:51,代码来源:SMW_QueryResult.php

示例6: getSparqlOptions

 /**
  * Get a SPARQL option array for the given query.
  *
  * @param SMWQuery $query
  * @param SMWSparqlCondition $sparqlCondition (storing order by variable names)
  * @return array
  */
 protected function getSparqlOptions(SMWQuery $query, SMWSparqlCondition $sparqlCondition)
 {
     global $smwgQSortingSupport, $smwgQRandSortingSupport;
     $result = array('LIMIT' => $query->getLimit() + 1, 'OFFSET' => $query->getOffset());
     // Build ORDER BY options using discovered sorting fields.
     if ($smwgQSortingSupport) {
         $orderByString = '';
         foreach ($this->m_sortkeys as $propkey => $order) {
             if ($order != 'RANDOM' && array_key_exists($propkey, $sparqlCondition->orderVariables)) {
                 $orderByString .= "{$order}(?" . $sparqlCondition->orderVariables[$propkey] . ") ";
             } elseif ($order == 'RANDOM' && $smwgQRandSortingSupport) {
                 // not supported in SPARQL; might be possible via function calls in some stores
             }
         }
         if ($orderByString !== '') {
             $result['ORDER BY'] = $orderByString;
         }
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:SMW_SparqlStoreQueryEngine.php

示例7: getSQLOptions

 /**
  * Get a SQL option array for the given query and preprocessed query object at given id.
  *
  * @param SMWQuery $query
  * @param integer $rootid
  */
 protected function getSQLOptions(SMWQuery $query, $rootid)
 {
     global $smwgQSortingSupport, $smwgQRandSortingSupport;
     $result = array('LIMIT' => $query->getLimit() + 1, 'OFFSET' => $query->getOffset());
     // Build ORDER BY options using discovered sorting fields.
     if ($smwgQSortingSupport) {
         $qobj = $this->m_queries[$rootid];
         foreach ($this->m_sortkeys as $propkey => $order) {
             if ($order != 'RANDOM' && array_key_exists($propkey, $qobj->sortfields)) {
                 // Field was successfully added.
                 $result['ORDER BY'] = (array_key_exists('ORDER BY', $result) ? $result['ORDER BY'] . ', ' : '') . $qobj->sortfields[$propkey] . " {$order} ";
             } elseif ($order == 'RANDOM' && $smwgQRandSortingSupport) {
                 $result['ORDER BY'] = (array_key_exists('ORDER BY', $result) ? $result['ORDER BY'] . ', ' : '') . ' RAND() ';
             }
         }
     }
     return $result;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:24,代码来源:SMW_SQLStore3_Queries.php

示例8: getSQLOptions

 /**
  * Get a SQL option array for the given query and preprocessed query object at given id.
  *
  * @param Query $query
  * @param integer $rootId
  *
  * @return array
  */
 private function getSQLOptions(Query $query, $rootId)
 {
     $result = array('LIMIT' => $query->getLimit() + 5, 'OFFSET' => $query->getOffset());
     // Build ORDER BY options using discovered sorting fields.
     if ($this->engineOptions->get('smwgQSortingSupport')) {
         $qobj = $this->querySegments[$rootId];
         foreach ($this->sortKeys as $propkey => $order) {
             if (!is_string($propkey)) {
                 throw new RuntimeException("Expected a string value as sortkey");
             }
             // #835
             // SELECT DISTINCT and ORDER BY RANDOM causes an issue for postgres
             // Disable RANDOM support for postgres
             if ($this->store->getConnection()->getType() === 'postgres') {
                 $this->engineOptions->set('smwgQRandSortingSupport', false);
             }
             if ($order != 'RANDOM' && array_key_exists($propkey, $qobj->sortfields)) {
                 // Field was successfully added.
                 $result['ORDER BY'] = (array_key_exists('ORDER BY', $result) ? $result['ORDER BY'] . ', ' : '') . $qobj->sortfields[$propkey] . " {$order} ";
             } elseif ($order == 'RANDOM' && $this->engineOptions->get('smwgQRandSortingSupport')) {
                 $result['ORDER BY'] = (array_key_exists('ORDER BY', $result) ? $result['ORDER BY'] . ', ' : '') . ' RAND() ';
             }
         }
     }
     return $result;
 }
开发者ID:bogota,项目名称:SemanticMediaWiki,代码行数:34,代码来源:QueryEngine.php

示例9: getOptions

 /**
  * Get a SPARQL option array for the given query.
  *
  * @param Query $query
  * @param Condition $compoundCondition (storing order by variable names)
  *
  * @return array
  */
 protected function getOptions(Query $query, Condition $compoundCondition)
 {
     $result = array('LIMIT' => $query->getLimit() + 1, 'OFFSET' => $query->getOffset());
     // Build ORDER BY options using discovered sorting fields.
     if ($this->engineOptions->get('smwgQSortingSupport')) {
         $orderByString = '';
         foreach ($query->sortkeys as $propkey => $order) {
             if (!is_string($propkey)) {
                 throw new RuntimeException("Expected a string value as sortkey");
             }
             if ($order != 'RANDOM' && array_key_exists($propkey, $compoundCondition->orderVariables)) {
                 $orderByString .= "{$order}(?" . $compoundCondition->orderVariables[$propkey] . ") ";
             } elseif ($order == 'RANDOM' && $this->engineOptions->get('smwgQRandSortingSupport')) {
                 // not supported in SPARQL; might be possible via function calls in some stores
             }
         }
         if ($orderByString !== '') {
             $result['ORDER BY'] = $orderByString;
         }
     }
     return $result;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:30,代码来源:QueryEngine.php

示例10: serializeParams

 /**
  * Serializes parameters and extraprintouts of SMWQuery.
  * These informations are needed to generate a correct SPARQL query.
  *
  * @param SMWQuery $query
  * @return string
  */
 protected function serializeParams($query)
 {
     $result = "";
     $first = true;
     foreach ($query->getExtraPrintouts() as $printout) {
         if (!$first) {
             $result .= "|";
         }
         if ($printout->getData() == NULL) {
             $result .= "?=" . $printout->getLabel();
         } else {
             if ($printout->getData() instanceof Title) {
                 $outputFormat = $printout->getOutputFormat() !== NULL ? "#" . $printout->getOutputFormat() : "";
                 $result .= "?" . $printout->getData()->getDBkey() . $outputFormat . "=" . $printout->getLabel();
             } else {
                 if ($printout->getData() instanceof SMWPropertyValue) {
                     $outputFormat = $printout->getOutputFormat() !== NULL ? "#" . $printout->getOutputFormat() : "";
                     $result .= "?" . array_shift($printout->getData()->getDBkeys()) . $outputFormat . "=" . $printout->getLabel();
                 }
             }
         }
         $first = false;
     }
     if ($query->getLimit() != NULL) {
         if (!$first) {
             $result .= "|";
         }
         $result .= "limit=" . $query->getLimit();
         $first = false;
     }
     if ($query->getOffset() != NULL) {
         if (!$first) {
             $result .= "|";
         }
         $result .= "offset=" . $query->getOffset();
         $first = false;
     }
     if ($query->sort) {
         if (!$first) {
             $result .= "|";
         }
         $first = false;
         $sort = "sort=";
         $order = "order=";
         $firstsort = true;
         foreach ($query->sortkeys as $sortkey => $orderkey) {
             if (!$firstsort) {
                 $sort .= ",";
                 $order .= ",";
             }
             $sort .= $sortkey;
             $order .= $orderkey;
             $firstsort = false;
         }
         $result .= $sort . "|" . $order;
     }
     if ($query->mergeResults === false) {
         if (!$first) {
             $result .= "|";
         }
         $result .= 'merge=false';
         $first = false;
     }
     if (isset($query->params) && isset($query->params['dataspace'])) {
         if (!$first) {
             $result .= "|";
         }
         $result .= 'dataspace=' . trim($query->params['dataspace']);
         $first = false;
     }
     return $result;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:79,代码来源:SMW_TripleStore.php


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