Structures
Most of data structures handled by SPARQLer actually extend those from EasyRDF, to provide some extra ability.
Graph
Usually returned by doCostruct() function, contains multiple Resources. Extends the EasyRdf\Graph class and:
- implements the Iterator inteface, so to be iterable in a loop
-
all properties added, removed or changed in child Resources are intercepted, stored in an internal structure, and can be saved back to the database using the
commit()
method$graph = $client->doConstruct()->where('rdf:search', 'foobar')->get(); foreach($graph as $resource) { $resource->set('rdf:predicate', 'value'); } $graph->commit();
Resource
Extends the EasyRdf\Resource class and adds a few features:
-
all changes are internally recorded to permit the
commit()
of the parent Graph -
the
p()
method is a convenient shortcut for get() converting all Literal to their plain, scalar value. -
the
remove()
method permits to delete the whole Resource from the database (not only the properties actually loaded)$graph = $client->doConstruct()->where('rdf:search', 'foobar')->get(); foreach($graph as $resource) { if ($resource->p('rdf:predicate') == 'value') { $resource->remove(); } }