SPARQL API examples

Last modified: February 18, 2008 - 05:36

The following examples illustrate SPARQL API usage.

Query builders

<?php
 
// Does there exist a user by the name john.smith?
 
sparql_ask()->
   
where('?user', rdf::type, rdf_curie('drupal:user'))->
   
where('?user', dc::title, 'john.smith');

 
// Select the titles of all blog posts promoted to the front page
 
sparql_select('?title')->
   
where('?node', rdf::type, rdf_curie('drupal:node'))->
   
where('?node', 'node:type', 'blog')->
   
where('?node', 'node:promote', TRUE)->
   
where('?node', 'node:title', rdf_var('?title'));
?>

 
 

Drupal is a registered trademark of Dries Buytaert.