I am trying to execute an INSERT on a SPARQL endpoint in PHP using the ARC2 library. This fails with the error "Could not properly handle " PREFIX dc:"
The SPARQL UPDATE query is taken from the W3C specification and works just fine on my Jena-Fuseki control panel:
$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" .
}
';
But even variations of the query without a PREFIX statement just result in a similar error "Could not properly handle " INSERT DATA {" in my PHP code.
My PHP code is as follows:
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);
This version is using a native ARC2 store to reduce potential error sources. I am actually trying to interact with a remote store:
$config = array( 'remote_store_endpoint' => 'http://localhost:3030/data/update', );
$store = ARC2::getRemoteStore($config);
Both give me the same error, however.
In the end I want to connect to the remote SPARQL endpoint of my Jena Fuseki server and interactively insert and retrieve data with that in PHP. If you have any other libraries or clean solutions how to interact through the SPARQL protocol in PHP, I am happy to change my approach.