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)

boolean
getBoolean()

Return the boolean value of the query result

boolean
isTrue()

Return true if the result of the query was true.

boolean
isFalse()

Return false if the result of the query was false.

integer
numFields()

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

integer
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.

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 70
__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 90
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 The query result type.

at line 103
boolean 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

boolean The result of the query.

at line 112
boolean isTrue()

Return true if the result of the query was true.

Return Value

boolean True if the query result was true.

at line 121
boolean isFalse()

Return false if the result of the query was false.

Return Value

boolean True if the query result was false.

at line 130
integer numFields()

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

Return Value

integer The number of fields.

at line 139
integer numRows()

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

Return Value

integer The number of rows.

at line 148
array getFields()

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

Return Value

array The names of the fields in the result.

at line 163
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 253
protected newTerm($data)

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

Parameters

$data

at line 275
protected parseXml($data)

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

Parameters

$data

at line 347
protected parseJson($data)

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

Parameters

$data

at line 382
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 A string representation of the result.