class Result extends ArrayIterator

Class for returned for SPARQL SELECT and ASK query responses.

Constants

SPARQL_XML_RESULTS_NS

A constant for the SPARQL Query Results XML Format namespace

Methods

__construct(string $data, string $mimeType)

Create a new SPARQL Result object

string
getType()

Get the query result type (boolean/bindings)

bool
getBoolean()

Return the boolean value of the query result

bool
isTrue()

Return true if the result of the query was true.

bool
isFalse()

Return false if the result of the query was false.

int
numFields()

Return the number of fields in a query result of type bindings.

int
numRows()

Return the number of rows in a query result of type bindings.

array
getFields()

Get the field names in a query result of type bindings.

string
dump(string $format = 'html')

Return a human readable view of the query result.

newTerm($data)

Create a new EasyRdf\Resource or EasyRdf\Literal depending on the type of data passed in.

startElementHandler($parser)

XML Result Parser: this function is called when an XML element starts

textHandler($parser)

XML Result Parser: this function is called when text is encountered

endElementHandler($parser)

XML Result Parser: this function is called when an XML element ends

parseXml($data)

Parse a SPARQL result in the XML format into the object.

parseJson($data)

Parse a SPARQL result in the JSON format into the object.

string
__toString()

Magic method to return value of the result to string

Details

at line 78
__construct(string $data, string $mimeType)

Create a new SPARQL Result object

You should not normally need to create a SPARQL result object directly - it will be constructed automatically for you by EasyRdf\Sparql_Client.

Parameters

string $data The SPARQL result body
string $mimeType The MIME type of the result

Exceptions

Exception

at line 98
string getType()

Get the query result type (boolean/bindings)

ASK queries return a result of type 'boolean'. SELECT query return a result of type 'bindings'.

Return Value

string

at line 111
bool getBoolean()

Return the boolean value of the query result

If the query was of type boolean then this method will return either true or false. If the query was of some other type then this method will return null.

Return Value

bool

at line 120
bool isTrue()

Return true if the result of the query was true.

Return Value

bool

at line 129
bool isFalse()

Return false if the result of the query was false.

Return Value

bool

at line 138
int numFields()

Return the number of fields in a query result of type bindings.

Return Value

int

at line 147
int numRows()

Return the number of rows in a query result of type bindings.

Return Value

int

at line 156
array getFields()

Get the field names in a query result of type bindings.

Return Value

array

at line 171
string dump(string $format = 'html')

Return a human readable view of the query result.

This method is intended to be a debugging aid and will return a pretty-print view of the query result.

Parameters

string $format Either 'text' or 'html'

Return Value

string

Exceptions

Exception

at line 261
protected newTerm($data)

Create a new EasyRdf\Resource or EasyRdf\Literal depending on the type of data passed in.

Parameters

$data

at line 283
startElementHandler($parser)

XML Result Parser: this function is called when an XML element starts

Parameters

$parser

at line 335
textHandler($parser)

XML Result Parser: this function is called when text is encountered

Parameters

$parser

at line 344
endElementHandler($parser)

XML Result Parser: this function is called when an XML element ends

Parameters

$parser

at line 369
protected parseXml($data)

Parse a SPARQL result in the XML format into the object.

Parameters

$data

at line 390
protected parseJson($data)

Parse a SPARQL result in the JSON format into the object.

Parameters

$data

at line 425
string __toString()

Magic method to return value of the result to string

If this is a boolean result then it will return 'true' or 'false'. If it is a bindings type, then it will dump as a text based table.

Return Value

string