2017 © Pedro Peláez
 

library sparql

Library that generate SPARQL queries and request a endpoints

image

legrand/sparql

Library that generate SPARQL queries and request a endpoints

  • Monday, January 12, 2015
  • by damien_legrand
  • Repository
  • 1 Watchers
  • 3 Stars
  • 81 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SPARQL for PHP

A library that generate SPARQL queries and request a endpoints, (*1)

Exemple

A quick and easy sparql request to understand how it works. You can find more exemples in the SparqlTest.php file., (*2)

    $sparql = new Legrand\SPARQL;

    $sparql->variable('?z')
           ->where('<http://dbpedia.org/resource/Nine_Inch_Nails>', '?y', '?z')
           ->limit(20);

    $response = $sparql->launch();

Methods

  • prefixe($namespace, $url) You can add several prefixes with this method
  • distinct($boolean) Set a request with a distinct select
  • variable($var) Add a variable to select i.e. ?z
  • from($graph) Add a from graph i.e. http://graph
  • where($subject, $predicate, $object) add a where condition
  • optionalWhere($subject, $predicate, $object) add a conditional where condition
  • optionalWhereComplexe($sparql) add a more complex conditional where in the query
  • union($sparql) define where condition on a SPARQL object and give it to this method
  • filter($filter) add a filter inside the where brackets
  • orderBy($order) define the order i.e. ?z DESC
  • limit($nb) define the limit
  • offset($nb) define the offset
  • insert($graph) create an insert sparql query by giving the graph uri
  • delete($graph) create a delete sparql query by giving the graph uri
  • getSPARQL() get the SPARQL query without calling the endpoint

Defaults

Some attributes are set with defaults value. You can of course change these values :, (*3)

  • $sparql->baseUrl = 'http://dbpedia.org/sparql';
  • $sparql->format = 'json';
  • $sparql->method = 'GET';
  • $sparql->queryParam = 'query';
  • $sparql->formatParam = 'format';

The Versions

12/01 2015

dev-master

9999999-dev http://github.com/snoozeman/sparql-php

Library that generate SPARQL queries and request a endpoints

  Sources   Download

MIT

The Requires

 

by Damien Legrand

semantic web sparql