Community Documentation

SPARQL API examples

Last updated February 18, 2008. Created by Arto on February 18, 2008.
Log in to edit this page.

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'));
?>

About this page

Drupal version
Drupal 6.x

Develop for Drupal

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.