Insert and Delete
doInsert()
and doDelete()
are used to insert and delete data into the graph. Both accept an array of Triples to specify what to insert or remove, while the conditions appended to the Builder define which entities are the target of insert or remove operation.
use MadBob\Sparqler\Terms\Iri;
$client->doInsert([
['foaf:knows', new Iri('http://mydomain/Person/Foo')],
])->where('foaf:currentProject', new Iri('http://mydomain/Project/Bar'))->run();
Show generated query
use MadBob\Sparqler\Terms\Iri;
$client->doDelete([
['foaf:knows', new Iri('http://mydomain/Person/Foo')],
])->where('foaf:currentProject', new Iri('http://mydomain/Project/Bar'))->run();
Show generated query
If you want to perform multiple insert/delete operations (for example, to update some value or relation) you can use the queue()
function instead of run()
, and execute all queries at once with runQueue()
use MadBob\Sparqler\Terms\Iri;
use MadBob\Sparqler\Terms\Variable;
$client->doDelete([
['foaf:knows', new Variable()],
])->where('foaf:currentProject', new Iri('http://mydomain/Project/Bar'))->queue();
$client->doInsert([
['foaf:knows', new Iri('http://mydomain/Person/Foo')],
])->where('foaf:currentProject', new Iri('http://mydomain/Project/Bar'))->queue();
$client->runQueue();
Show generated query