我正在尝试EasyRdf_Graph
从通过发送的查询中获取对象EasyRdf_Sparql_Client::query
。
SELECT
和ASK
查询将返回一个类型的对象EasyRdfSparqlResult
。
CONSTRUCT
和DESCRIBE
查询将返回一个类型的对象EasyRdf_Graph
。
这是我的代码:
<?php
require APPPATH .'third_party/vendor/autoload.php';
$endpointUrl = "http://data.bnf.fr/sparql";
$dummyConstructQueryString = "construct { ?s ?q ?r } where { ?s ?p ?o . ?o ?q ?r } limit 1";
$endPoint = new EasyRdf_Sparql_Client($endpointUrl);
$result = $endPoint->query($dummyConstructQueryString);
var_dump($result);
echo $result;
?>
这是输出,EasyRdf_Sparql_Result
如您所见:
object(**EasyRdf_Sparql_Result**)#47 (6) {
["type":"EasyRdf_Sparql_Result":private]=>
string(8) "bindings"
["boolean":"EasyRdf_Sparql_Result":private]=>
NULL
["ordered":"EasyRdf_Sparql_Result":private]=>
NULL
["distinct":"EasyRdf_Sparql_Result":private]=>
NULL
["fields":"EasyRdf_Sparql_Result":private]=>
array(3) {
[0]=>
string(1) "s"
[1]=>
string(1) "p"
[2]=>
string(1) "o"
}
["storage":"ArrayIterator":private]=>
array(1) {
[0]=>
object(stdClass)#48 (3) {
["s"]=>
object(EasyRdf_Resource)#49 (2) {
["uri":protected]=>
string(56) "http://www.w3.org/ns/sparql-service-description#endpoint"
["graph":protected]=>
NULL
}
["p"]=>
object(EasyRdf_Resource)#50 (2) {
["uri":protected]=>
string(47) "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
["graph":protected]=>
NULL
}
["o"]=>
object(EasyRdf_Resource)#51 (2) {
["uri":protected]=>
string(42) "http://www.w3.org/2000/01/rdf-schema#Class"
["graph":protected]=>
NULL
}
}
}
}
+-------------+----------+------------+
| ?s | ?p | ?o |
+-------------+----------+------------+
| sd:endpoint | rdf:type | rdfs:Class |
还尝试了不同的端点(http://dbpedia.org/sparql和http://localhost:3030/testFuseki) 因为我看到了这个问题:https ://github.com/njh/easyrdf/issues/226 ,但它是一样的。
有关安装的信息
随 Composer 一起安装的 EasyRDF 版本 0.9.1
PHP 版本 7.0.30-0+deb9u1 + Apache/2.4.25 (Debian)
任何线索将不胜感激,在此先感谢。
编辑
实际上它适用于我本地安装的 Fuseki。由于http://data.bnf/fr/sparql和http://dbpedia.org/sparql都是 Virtuoso 端点,我想知道问题是否仅出在 Virtuoso 上。