コード例 #1
0
 */
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
require_once "html_tag_helpers.php";
$sparql = new EasyRdf_Sparql_Client('http://127.0.0.1:3030/ds/query', 'http://127.0.0.1:3030/ds/update');
?>
<html>
<head>
  <title>EasyRdf Basic Sparql Example</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>EasyRdf Basic Sparql Example</h1>

<?php 
print "Count: " . $sparql->countTriples() . "<br />\n";
$result = $sparql->clear('all');
print "Result: " . $result->getMessage() . "<br />\n";
$graph = new EasyRdf_Graph();
$person = $graph->resource('http://example.com/joe', 'foaf:Person');
$person->add('foaf:name', 'Joe');
$result = $sparql->insert($graph, 'http://example.com/joe');
$result = $sparql->insert('<s> <p> <o>', 'http://example.org/1');
print "Result: " . $result->getMessage() . "<br />\n";
$result = $sparql->insert('<s> <p> <o>', 'http://example.org/2');
print "Result: " . $result->getMessage() . "<br />\n";
$result = $sparql->insert('<s> <p> <o>', 'http://example.org/2');
print "Result: " . $result->getMessage() . "<br />\n";
//     $result = $sparql->load('http://www.dajobe.org/foaf.rdf');
//     print "Result: ".$result->getMessage()."<br />\n";
print "Count: " . $sparql->countTriples() . "<br />\n";
コード例 #2
0
 public function testCountTriplesWithCondition()
 {
     $this->client->addMock('GET', '/sparql?query=PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0A' . 'SELECT+%28COUNT%28%2A%29+AS+%3Fcount%29+%7B%3Fs+a+foaf%3APerson%7D', readFixture('sparql_select_count_zero.json'), array('headers' => array('Content-Type' => 'application/sparql-results+json; charset=utf-8')));
     $count = $this->sparql->countTriples('?s a foaf:Person');
     $this->assertSame(0, $count);
 }