Construct
doConstruct()
returns a Graph, including multiple Resource, and permits an accurate selection of predicates to be fetched and added to the Graph itself.
$client->doConstruct([['rdf:predicate1'], ['rdf:predicate2']])
->where('rdf:search', 'foobar')->get();
Show generated query
doConstruct()
gets an optional array of Triple as parameters, describing the properties you want to fetch for each entity matching the conditions, but usually you may want to omit the subject (implicit, due the conditions appended to the Builder) and the object (which is automatically mapped into the query for each required predicate). If no parameters are passed, all the predicates of matching entities are fetched from the endpoint.
The returned value is an instance of MadBob\Sparqler\Graph
, an iterable data structure which also tracks all modifications operated on the child resources and exposes a commit()
method to save them all back to the triplestore.
$graph = $client->doConstruct()->where('rdf:predicate', 'foobar')->get();
foreach($graph as $resource) {
$resource->set('new:predicate', 'new value');
}
$graph->commit();
Show generated query
For convenience, Client has a short hand find()
function which CONSTRUCTs a given subject.
$client->find('https://example.com/resource/sample');
Show generated query