function _insertData($graph, $triples, $expected_count = NULL, $options = array()) { $count = $this->countQuads(); $rs = rdfdb_insert_data($graph, $triples)->execute(); if ($expected_count) { // Find out how many triples were inserted via SPARQL querying. $inserted1 = $this->countQuads() - $count; // @todo get this bug fixed in ARC2, see $this->assertEqual($inserted1, $expected_count, "{$expected_count} triples were inserted according to SPARQL querying [%s]"); } }
$rdfdb_connections['rdfdb1']['default'] = array('driver' => 'arc2', 'endpoint' => 'http://localhost/d7git3/sparql', 'apikey' => 'somekey'); $rdfdb_connections['rdfdb2']['default'] = array('driver' => '4store', 'endpoint' => 'http://localhost:8080/data/', 'apikey' => ''); $rdfdb_connections['rdfdb3']['default'] = array('driver' => 'virtuoso', 'endpoint' => 'http://localhost:18890/sparql', 'apikey' => ''); Rdfdb::addConnectionInfo('default', 'default', $rdfdb_connections['rdfdb3']['default']); rdfdb_set_active('defaut'); //var_dump(rdfdb_insert_data('http://example/bookStore', '<http://example/book4> <http://ex.org/title> "Fundamentals of Compiler Desig4n"')->execute()); //var_dump(Rdfdb::getConnectionInfo('default')); //echo realpath(dirname(__FILE__)); // Insert data into a graph // INSERT DATA { graph_triples } // graph_triples :: = TriplesBlock | GRAPH <graph_uri> { TriplesBlock } // INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book3> dc:title "Fundamentals of Compiler Design" } } // ARC2 INSERT INTO <http://example.com/> { <#foo> <bar> "baz" .} //var_dump(rdfdb_insert_data('http://example/bookStore', '<http://example/book3> <http://ex.org/title> "Fundamentals of Compiler Design"')->execute()); rdfdb_insert_data('http://example/bookStore', '<http://example/book3> <http://ex.org/title> "Fundamentals of Compiler Design"')->execute(); rdfdb_insert_data('http://example/bookStore', '<http://example/book4> <http://ex.org/title> "Fundamentals of Compiler Design4"')->execute(); // An array containing prefix and namespaces as name/value pairs. $options = array('namespaces' => array('dc' => 'http://purl.org/dc/terms/')); //var_dump(rdfdb_insert_data('http://example/bookStore', '<http://example/book3> dc:title "Fundamentals of Compiler Design with ns34"', $options)->execute()); /////////////////////////////////////////////////// /////////////////////////////////////////////////// // Delete data from a graph // DELETE DATA { graph_triples } // graph_triples :: = TriplesBlock | GRAPH <graph_uri> { TriplesBlock } //rdfdb_delete_data($graph_triples) // DELETE FROM <http://example/bookStore> // DELETE { ?s ?p ?o . } WHERE { ?s ?p ?o . } //var_dump(rdfdb_delete_data(NULL, '<http://example/book3> <http://ex.org/title> "Fundamentals of Compiler Design"')->execute()); //var_dump(rdfdb_delete_data('http://example/bookStore', '<http://example/book4> <http://ex.org/title> "Fundamentals of Compiler Design"')->execute()); //rdfdb_select('?s ?p ?o', $options)->where('?s ?p ?o')->execute(); $rs = rdfdb_clear('http://example/bookStore', $options)->execute();