本文整理汇总了PHP中SMWQuery::getQueryString方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQuery::getQueryString方法的具体用法?PHP SMWQuery::getQueryString怎么用?PHP SMWQuery::getQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQuery
的用法示例。
在下文中一共展示了SMWQuery::getQueryString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getLink
/**
* Returns an SMWInfolink object with the QueryResults print requests as parameters.
*
* @since 1.8
*
* @return SMWInfolink
*/
public function getLink()
{
$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;
}
}
// Note: the initial : prevents SMW from reparsing :: in the query string.
return SMWInfolink::newInternalLink('', ':Special:Ask', false, $params);
}
示例3: 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;
}
示例4: doGetQueryResult
function doGetQueryResult(SMWQuery $query)
{
global $wgServer, $wgScript, $smwgWebserviceUser, $smwgWebservicePassword, $smwgDeployVersion;
// handle only SPARQL queries and delegate all others
if ($query instanceof SMWSPARQLQuery) {
// wfRunHooks('RewriteSparqlQuery', array(&$query) );
if ($query->getQueryString() == "") {
$sqr = new SMWHaloQueryResult(array(), $query, array(), $this, false);
$sqr->addErrors(array(wfMsgForContent('hacl_sp_empty_query')));
return $sqr;
}
try {
$con = TSConnection::getConnector();
$con->connect();
$response = $con->query($query->getQueryString(), $this->serializeParams($query));
global $smwgSPARQLResultEncoding;
// PHP strings are always interpreted in ISO-8859-1 but may be actually encoded in
// another charset.
if (isset($smwgSPARQLResultEncoding) && $smwgSPARQLResultEncoding == 'UTF-8') {
$response = utf8_decode($response);
}
$queryResult = $this->parseSPARQLXMLResult($query, $response);
} catch (Exception $e) {
switch ($query->querymode) {
case SMWQuery::MODE_COUNT:
$sqr = $e->getMessage();
break;
default:
$sqr = new SMWHaloQueryResult(array(), $query, array(), $this);
if ($e->getCode() == 0) {
// happens most likely when TSC is not running
global $smwgWebserviceEndpoint;
$sqr->addErrors(array(wfMsg('smw_ts_notconnected', $smwgWebserviceEndpoint)));
} else {
$sqr->addErrors(array($e->getMessage()));
}
break;
}
return $sqr;
}
// wfRunHooks('FilterQueryResults', array(&$queryResult) );
switch ($query->querymode) {
case SMWQuery::MODE_COUNT:
$queryResult = $queryResult->getCount();
break;
default:
break;
}
return $queryResult;
} else {
return $this->smwstore->getQueryResult($query);
}
}