-
Notifications
You must be signed in to change notification settings - Fork 27
Queries
To issue a query with Erfurt you first get the store and then call the sparqlQuery-method:
Erfurt_App::getInstance()->getStore()->sparqlQuery(...);
The sparqlQuery-method accepts three types of arguments:
- string: the query as a string Erfurt_App::getInstance()->getStore()->sparqlQuery("SELECT * WHERE {...}");
- a SimpleQuery object: $sqo = new Erfurt_Sparql_SimpleQuery(); ... Erfurt_App::getInstance()->getStore()->sparqlQuery($sqo);
- a Query2 object: $q = Erfurt_Sparql_Query2(); ... new Erfurt_App::getInstance()->getStore()->sparqlQuery($q);
why is that? Internally the sparqlQuery-method needs to
- analyze the query and modify it according to Access Controll (Erfurt features a per-model AC. if the query is issued by user x, the FROM-declarations are checked if they match the readable models configured)
- send it to a triple store, return the results
SimpleQuery and Query2 represent a query; the have methods to get and change specific parts of the query. Also the have a toString-method, that is called to get the actual query to send it to the store. A string query is transformed into a SimpleQuery object (by some Regexes. see Erfurt_Sparql_SimpleQuery::initWithString("SELECT * WHERE{...}");).
The SimpleQuery class is rather light-weight; the WHERE-part is not parsed. The Query2 class allows the modification of a query to the last details of the SPARQL-grammar. A string can be parsed to a Query2 object with the new SPARQL-parser (Erfurt_Sparql_Query2::initWithString("SELECT * WHERE{...}");).