EasyRDF 0.9.0 and Virtuoso

Submitted by admin on Thu, 04/02/2015 - 16:16

This code works following SPARQL UPDATE 1.1

<code>
$gs = new EasyRdf_Sparql_Client('http://localhost:8890/sparql&#039;);
$graph1 = new EasyRdf_Graph();
$graph1->add('http://example.com/test&#039;, 'rdfs:label', 'TestAdam');
$graph1->add('http://example.com/test&#039;, 'dc:date', time());
$gs->insert($graph1, 'http://library.landportal.info&#039;);
</code>

This code works following SPARQL 1.1 Graph Store. Take in account that Virtuoso uses an special SPARQL Endpoint

<code>
$gs = new EasyRdf_GraphStore('http://37.187.148.108:8890/sparql-graph-crud&#039;);
$graph1 = new EasyRdf_Graph();
$graph1->add('http://example.com/test&#039;, 'rdfs:label', 'TestVale');
$graph1->add('http://example.com/test&#039;, 'dc:date', time());
$gs->insert($graph1, 'http://library.landportal.info&#039;);
</code>

and.. if you want to use SPARUL

<code>
class EasyRdf_Sparql_Client2 extends EasyRdf_Sparql_Client {

public function insert($data, $graphUri = null)
{
$query = 'INSERT INTO ';
if ($graphUri) {
$query .= "GRAPH <$graphUri> {";
}
$query .= $this->convertToTriples($data);
if ($graphUri) {
$query .= "}";
}
return $this->request('query', $query);
}

public function clear($graphUri, $silent = false)
{
$query = "CLEAR";
if ($silent) {
$query .= " SILENT";
}
if (preg_match('/^all|named|default$/i', $graphUri)) {
$query .= " $graphUri";
} else {
$query .= " GRAPH <$graphUri>";
}
return $this->request('query', $query);
}
}

</code>

Etiquetas