class Client

Class for making SPARQL queries using the SPARQL 1.1 Protocol

Methods

__construct(string $queryUri, string $updateUri = null)

Create a new SPARQL endpoint client

string
getQueryUri()

Get the URI of the SPARQL query endpoint

string
getUpdateUri()

Get the URI of the SPARQL update endpoint

getUri()

No description

query(string $query)

Make a query to the SPARQL endpoint

integer
countTriples(string $condition = '?s ?p ?o')

Count the number of triples in a SPARQL 1.1 endpoint

listNamedGraphs(string $limit = null)

Get a list of named graphs from a SPARQL 1.1 endpoint

update(string $query)

Make an update request to the SPARQL endpoint

insert($data, $graphUri = null)

No description

updateData($operation, $data, $graphUri = null)

No description

clear($graphUri, $silent = false)

No description

request($type, $query)

No description

convertToTriples($data)

No description

string
preprocessQuery(string $query)

Adds missing prefix-definitions to the query

Response|Response
executeQuery(string $processed_query, string $type)

Build http-client object, execute request and return a response

parseResponseToQuery(Response|Response $response)

Parse HTTP-response object into a meaningful result-object.

Details

at line 70
__construct(string $queryUri, string $updateUri = null)

Create a new SPARQL endpoint client

If the query and update endpoints are the same, then you only need to give a single URI.

Parameters

string $queryUri The address of the SPARQL Query Endpoint
string $updateUri Optional address of the SPARQL Update Endpoint

at line 91
string getQueryUri()

Get the URI of the SPARQL query endpoint

Return Value

string The query URI of the SPARQL endpoint

at line 100
string getUpdateUri()

Get the URI of the SPARQL update endpoint

Return Value

string The query URI of the SPARQL endpoint

at line 109
getUri()

at line 126
Result|Graph query(string $query)

Make a query to the SPARQL endpoint

SELECT and ASK queries will return an object of type EasyRdf\Sparql\Result.

CONSTRUCT and DESCRIBE queries will return an object of type EasyRdf\Graph.

Parameters

string $query The query string to be executed

Return Value

Result|Graph Result of the query.

at line 142
integer countTriples(string $condition = '?s ?p ?o')

Count the number of triples in a SPARQL 1.1 endpoint

Performs a SELECT query to estriblish the total number of triples.

Counts total number of triples by default but a conditional triple pattern can be given to count of a subset of all triples.

Parameters

string $condition Triple-pattern condition for the count query

Return Value

integer The number of triples

at line 162
Resource[] listNamedGraphs(string $limit = null)

Get a list of named graphs from a SPARQL 1.1 endpoint

Performs a SELECT query to get a list of the named graphs

Parameters

string $limit Optional limit to the number of results

Return Value

Resource[] array of objects for each named graph

at line 188
Response update(string $query)

Make an update request to the SPARQL endpoint

Successful responses will return the HTTP response object

Unsuccessful responses will throw an exception

Parameters

string $query The update query string to be executed

Return Value

Response HTTP response

at line 193
insert($data, $graphUri = null)

Parameters

$data
$graphUri

at line 208
protected updateData($operation, $data, $graphUri = null)

Parameters

$operation
$data
$graphUri

at line 222
clear($graphUri, $silent = false)

Parameters

$graphUri
$silent

at line 241
protected request($type, $query)

Parameters

$type
$query

at line 258
protected convertToTriples($data)

Parameters

$data

at line 280
protected string preprocessQuery(string $query)

Adds missing prefix-definitions to the query

Overriding classes may execute arbitrary query-alteration here

Parameters

string $query

Return Value

string

at line 304
protected Response|Response executeQuery(string $processed_query, string $type)

Build http-client object, execute request and return a response

Parameters

string $processed_query
string $type Should be either "query" or "update"

Return Value

Response|Response

Exceptions

Exception

at line 383
protected Graph|Result parseResponseToQuery(Response|Response $response)

Parse HTTP-response object into a meaningful result-object.

Can be overridden to do custom processing

Parameters

Response|Response $response

Return Value

Graph|Result