EasyRdf API Documentation
Class

EasyRdf_Sparql_Client

class EasyRdf_Sparql_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()

object 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

array listNamedGraphs(string $limit = null)

Get a list of named graphs from a SPARQL 1.1 endpoint

object update(string $query)

Make an update request to the SPARQL endpoint

insert($data, $graphUri = null)

clear($graphUri, $silent = false)

Details

at line 63
public __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 84
public string getQueryUri()

Get the URI of the SPARQL query endpoint

Return Value

string The query URI of the SPARQL endpoint

at line 93
public string getUpdateUri()

Get the URI of the SPARQL update endpoint

Return Value

string The query URI of the SPARQL endpoint

at line 102
public getUri()

at line 118
public object query(string $query)

Make a query to the SPARQL endpoint

SELECT and ASK queries will return an object of type EasyRdfSparqlResult.

CONSTRUCT and DESCRIBE queries will return an object of type EasyRdf_Graph.

Parameters

string $query The query string to be executed

Return Value

object EasyRdfSparqlResult|EasyRdf_Graph Result of the query.

at line 133
public 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 152
public array 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

array Array of EasyRdf_Resource objects for each named graph

at line 177
public object 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

object EasyRdfHttpResponse HTTP response

at line 182
public insert($data, $graphUri = null)

Parameters

$data
$graphUri

at line 211
public clear($graphUri, $silent = false)

Parameters

$graphUri
$silent