【发布时间】:2014-11-10 17:27:22
【问题描述】:
我正在尝试使用ARC2 库在 PHP 中的 SPARQL 端点上执行 INSERT。 这将失败并出现错误“无法正确处理”PREFIX dc:”
SPARQL UPDATE 查询取自 W3C specification,在我的 Jena-Fuseki 控制面板上运行良好:
$query = '
PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA
{
<http://example/book007> dc:title "A new book" ;
dc:creator "A.N.Other" .
}
';
但即使没有 PREFIX 语句的查询变体也只会在我的 PHP 代码中导致类似的错误“无法正确处理”INSERT DATA {。
我的PHP代码如下:
include_once('./lib/arc2/ARC2.php');
$config = array(
//db
'db_name' => 'arc2',
'db_user' => 'root',
'db_pwd' => '-',
//store
'store_name' => 'arc_tests'
);
$store = ARC2::getStore($config);
if (!$store->isSetUp())
$store->setUp();
$res = $store->query($query);
echo var_dump($store->getErrors());
echo "<br><br>executed INSERT, returned: ";
echo var_dump($res);
此版本使用原生 ARC2 存储来减少潜在的错误来源。我实际上是在尝试与远程商店进行交互:
$config = array( 'remote_store_endpoint' => 'http://localhost:3030/data/update', );
$store = ARC2::getRemoteStore($config);
然而,两者都给我同样的错误。
最后,我想连接到我的 Jena Fuseki 服务器的 remote SPARQL 端点,并使用 PHP 交互地插入和检索数据。如果您有任何其他库或干净的解决方案如何通过 PHP 中的 SPARQL 协议进行交互,我很乐意改变我的方法。
【问题讨论】:
标签: php sparql semantic-web