Semantic MediaWiki and related extensions
Public Member Functions | Public Attributes | List of all members
SMWQuery Class Reference
Collaboration diagram for SMWQuery:
Collaboration graph
[legend]

Public Member Functions

 __construct (Description $description=null, $context=false)
 
 setQueryMode ($queryMode)
 
 getQueryMode ()
 
 setContextPage (DIWikiPage $contextPage=null)
 
 getContextPage ()
 
 setQuerySource ($querySource)
 
 getQuerySource ()
 
 setQueryToken (QueryToken $queryToken=null)
 
 getQueryToken ()
 
 setMainLabel ($mainlabel)
 
 getMainLabel ()
 
 setDescription (SMWDescription $description)
 
 getDescription ()
 
 setExtraPrintouts ($extraprintouts)
 
 getExtraPrintouts ()
 
 getErrors ()
 
 addErrors ($errors)
 
 setQueryString ($querystring)
 
 setOption ($key, $value)
 
 getOption ($key)
 
 getQueryString ($fresh=false)
 
 getOffset ()
 
 setOffset ($offset)
 
 getLimit ()
 
 setLimit ($limit, $restrictinline=true)
 
 setUnboundLimit ($limit)
 
 setSortKeys (array $sortKeys)
 
 getSortKeys ()
 
 applyRestrictions ()
 
 toArray ()
 
 getHash ()
 
 getAsString ()
 
 getQueryId ()
 

Public Attributes

const ID_PREFIX = '_QUERY'
 
const PROC_QUERY_TIME = 'proc.query.time'
 
const PROC_PRINT_TIME = 'proc.print.time'
 
const PROC_CONTEXT = 'proc.context'
 
const OPT_PARAMETERS = 'proc.parameters'
 
const NO_CACHE = 'no.cache'
 
const NO_DEPENDENCY_TRACE = 'no.dependency.trace'
 
 $sort = false
 
 $sortkeys = array()
 
 $querymode = self::MODE_INSTANCES
 
- Public Attributes inherited from SMW\Query\QueryContext
const SPECIAL_PAGE = 1000
 
const INLINE_QUERY = 1001
 
const CONCEPT_DESC = 1002
 
const MODE_INSTANCES = 1
 
const MODE_COUNT = 2
 
const MODE_DEBUG = 3
 
const MODE_NONE = 4
 

Detailed Description

Representation of queries in SMW, each consisting of a query description and various parameters. Some settings might also lead to changes in the query description.

Most additional query parameters (limit, sort, ascending, ...) are interpreted as in SMWRequestOptions (though the latter contains some additional settings).

Constructor & Destructor Documentation

SMWQuery::__construct ( Description  $description = null,
  $context = false 
)
Since
1.6
Parameters
Description$description
integer | boolean$context

Member Function Documentation

SMWQuery::addErrors (   $errors)
SMWQuery::applyRestrictions ( )

Apply structural restrictions to the current description.

SMWQuery::getAsString ( )
Since
2.5
Returns
string
SMWQuery::getContextPage ( )
Since
2.3
Returns
DIWikiPage|null
SMWQuery::getDescription ( )
SMWQuery::getErrors ( )
SMWQuery::getExtraPrintouts ( )
Returns
PrintRequest[]
SMWQuery::getHash ( )
Note
Before 2.5, toArray was used to generate the content, as of 2.5 only parameters that influence the result of an query is included.
Since
2.1
Returns
string
SMWQuery::getLimit ( )
SMWQuery::getMainLabel ( )

Gets the mainlabel.

Since
1.6.
Returns
string
SMWQuery::getOffset ( )
SMWQuery::getOption (   $key)
Since
2.5
Parameters
string | integer$key
Returns
mixed
SMWQuery::getQueryId ( )
Since
2.3
Returns
string
SMWQuery::getQueryMode ( )
Since
2.5
Parameters
integer
SMWQuery::getQuerySource ( )
Since
2.4
Returns
string
SMWQuery::getQueryString (   $fresh = false)
Since
1.7
Parameters
boolean$fresh
Returns
string
SMWQuery::getQueryToken ( )
Since
2.5
Returns
QueryToken|null
SMWQuery::getSortKeys ( )
Since
2.2
Returns
array
SMWQuery::setContextPage ( DIWikiPage  $contextPage = null)
Since
2.3
Parameters
DIWikiPage | null$contextPage
SMWQuery::setDescription ( SMWDescription  $description)
SMWQuery::setExtraPrintouts (   $extraprintouts)
SMWQuery::setLimit (   $limit,
  $restrictinline = true 
)

Set a limit for number of query results. The set limit might be restricted by the current offset so as to ensure that the number of the last considered result does not exceed the maximum amount of supported results. The function returns the chosen limit.

Note
It makes sense to have limit==0, e.g. to only show a link to the search special
SMWQuery::setMainLabel (   $mainlabel)

Sets the mainlabel.

Since
1.6.
Parameters
string$mainlabel
SMWQuery::setOffset (   $offset)

Set an offset for the returned query results. No offset beyond the maximal query limit will be set, and the current query limit might be reduced in order to ensure that no results beyond the maximal limit are returned. The function returns the chosen offset.

Todo:
The function should be extended to take into account whether or not we are in inline mode (not critical, since offsets are usually not applicable inline).
SMWQuery::setOption (   $key,
  $value 
)
Since
2.5
Parameters
string | integer$key
mixed$value
SMWQuery::setQueryMode (   $queryMode)
Since
2.5
Parameters
integer
SMWQuery::setQuerySource (   $querySource)
Since
2.4
Parameters
string
SMWQuery::setQueryString (   $querystring)
SMWQuery::setQueryToken ( QueryToken  $queryToken = null)
Since
2.5
Parameters
QueryToken | null$queryToken
SMWQuery::setSortKeys ( array  $sortKeys)
Note
format: "Property key" => "ASC" / "DESC" (note: order of entries also matters)
Since
2.2
Parameters
array$sortKeys
SMWQuery::setUnboundLimit (   $limit)
Note
Sets an unbound limit that is independent from GLOBAL settings
Since
2.0
Parameters
integer$limit
Returns
Query
SMWQuery::toArray ( )

Returns serialized query details

The output is following the askargs api module convention

conditions The query conditions (requirements for a subject to be included) printouts The query printouts (which properties to show per subject) parameters The query parameters (non-condition and non-printout arguments)

Since
1.9
Returns
array

Member Data Documentation

SMWQuery::$querymode = self::MODE_INSTANCES
SMWQuery::$sort = false
SMWQuery::$sortkeys = array()
const SMWQuery::ID_PREFIX = '_QUERY'
const SMWQuery::NO_CACHE = 'no.cache'

Suppress a possible cache request

const SMWQuery::NO_DEPENDENCY_TRACE = 'no.dependency.trace'

Indicates no dependency trace

const SMWQuery::OPT_PARAMETERS = 'proc.parameters'

The processing parameters

const SMWQuery::PROC_CONTEXT = 'proc.context'

The processing context in which the query is being executed

const SMWQuery::PROC_PRINT_TIME = 'proc.print.time'

The time a ResultPrinter required to build the final result including all PrintRequests

const SMWQuery::PROC_QUERY_TIME = 'proc.query.time'

The time the QueryEngine required to answer a query condition


The documentation for this class was generated from the following file: