Skip to content
Snippets Groups Projects
Commit 96d3e421 authored by Alvaro Graves's avatar Alvaro Graves
Browse files

Adding named graph when searching if URI exists (some implementations will make a difference)

Using ASK instead of select
using [] instead of variables in query
parent d94adb50
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,10 @@ class Endpoint{ ...@@ -45,6 +45,10 @@ class Endpoint{
if(preg_match("/construct/i", $q)){ if(preg_match("/construct/i", $q)){
return $aux; return $aux;
} }
if(preg_match("/ask/i", $q)){
$r = json_decode($aux, true);
return $r;
}
} }
public function queryPost($q){ public function queryPost($q){
......
...@@ -2,16 +2,25 @@ ...@@ -2,16 +2,25 @@
class Queries{ class Queries{
public static function uriExist($uri, $e){ public static function uriExist($uri, $e){
$q = "SELECT * WHERE{ $q = "ASK WHERE{
{<$uri> ?p1 ?o1} {
UNION GRAPH ?g{
{?s1 <$uri> ?o2} {<$uri> ?p1 []}
UNION UNION
{?s2 ?p2 <$uri>} {[] <$uri> []}
}LIMIT 1"; UNION
{[] ?p2 <$uri>}
$r = $e->query($q); }
if(sizeof($r['results']['bindings'])>0){ }UNION{
{<$uri> ?p1 []}
UNION
{[] <$uri> []}
UNION
{[] ?p2 <$uri>}
}
}";
$r = $e->query($q);
if($r['boolean'] && strtolower($r['boolean']) !== false){
return true; return true;
} }
return false; return false;
......
...@@ -12,7 +12,7 @@ class Utils{ ...@@ -12,7 +12,7 @@ class Utils{
public static function send404($uri){ public static function send404($uri){
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
echo "LODSPeaKr could not find ".$uri." or information about it.\n\n"; echo "LODSPeaKr could not find ".$uri." or information about it.\nNo URIs in the triple store, or services configured with that URI\n";
exit(0); exit(0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment