Sparql query in ARC2

366 views
Skip to first unread message

haklaekim

unread,
Jun 1, 2012, 12:38:14 PM6/1/12
to arc-dev
Hi there,

I am trying to get some data from the dbpedia endpoint using ARC2.
The following code is a sample that I want for a simple test. When I
run this code, I do not get any message.

include_once("/rdf/arc/ARC2.php");
$dbpconfig = array(
"remote_store_endpoint" => "http://dbpedia.org/sparql",
);
$dbpedia = ARC2::getRemoteStore($dbpconfig);

$dbpuri = "http://dbpedia.org/resource/2PM";

$query = "
SELECT ?name, ?wikipedia
WHERE
{ <$dbpuri> foaf:name ?name ;
foaf:page ?wikipedia .
}";

$dbpArtist = $dbpedia->query($query, 'row');

echo $dbpArtist['name'];

The query is worked well in endpoint (http://dbpedia.org/sparql). But,
with this code, a single parameter is allowed. For example, the
following query and code is fine. I have changed the code and query in
several times, I didn't find a solution so far. What is a problem?
Thanks in advance.

$query = "
SELECT ?name
WHERE
{ <$dbpuri> foaf:name ?name .
}";

- haklae

Stéphane Corlosquet

unread,
Jun 1, 2012, 12:42:09 PM6/1/12
to arc...@googlegroups.com
Hi Haklae,

  SELECT ?name, ?wikipedia

Have you tried without the comma?

Steph.

Stéphane Corlosquet

unread,
Jun 1, 2012, 12:51:47 PM6/1/12
to arc...@googlegroups.com
you're also missing 
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
at the top.

generally I find dumping the ARC2 class helps with debugging:
var_dump($dbpedia);
would have shown you the settings and errors.

Steph.

Kim Haklae

unread,
Jun 13, 2012, 9:48:52 PM6/13/12
to arc...@googlegroups.com
Thanks. Without comma works fine :)

Haklae.
--
Dr.Dr. Haklae Kim
Senior Engineer
Service Platform Group
Media Solution Center, DMC
Samsung Electronics, Co. Ltd.
Tel: +82-(0)10-3201-0714
Who's Who in the World's 27th Edition - 2010

Reply all
Reply to author
Forward
0 new messages