#!/usr/bin/php setEndpointQuery($endpointQueryOnly); $ENDPOINT->setEndpointUpdate($endpointUpdateOnly); $ENDPOINT->setNameParameterQueryRead($nameParameterQuery); $ENDPOINT->setNameParameterQueryWrite($nameParameterUpdate); } switch($typeOutput){ case "txt": $type = "text/plain"; case "csv": $type = "text/csv; charset=utf-8"; break; case "tsv": $type = "text/tab-separated-values; charset=utf-8"; break; case "ttl": $type = "text/turtle"; break; case "srx": $type = "application/sparql-results+xml"; break; case "srj": $type = "application/sparql-results+json"; break; default : $type = $typeOutput; } if($modeVerbose){ echo " Configuration : - Endpoint query : ".$ENDPOINT->getEndpointQuery()." - Endpoint update : ".$ENDPOINT->getEndpointUpdate()." - Mode verbose : ".($modeVerbose?"ON":"OFF")." - Mode debug : ".($modeDebug?"ON":"OFF")." - Type output : ".$type." "; } ///////// $ENDPOINT->ResetErrors(); //queryRead /* $rows = $ENDPOINT->query( file_get_contents($filename), 'rows'); $err = $ENDPOINT->getErrors(); if ($err) { echo "ERROR \n"; print_r($err,true); exit(); } foreach($rows["result"]["variables"] as $variable){ printf("%-20.20s",$variable); echo '|'; } echo "\n"; foreach ($rows["result"]["rows"] as $row){ foreach($rows["result"]["variables"] as $variable){ printf("%-20.20s",$row[$variable]); echo '|'; } echo "\n"; } */ if($modeRead) $response = $ENDPOINT->queryRead( file_get_contents($filename),$type); elseif ($modeWrite) $response = $ENDPOINT->queryUpdate( file_get_contents($filename),$type); else{ echo "ERROR : forget parameter after -r or -w (see --help)\n"; exit(); } $err = $ENDPOINT->getErrors(); if ($err) { echo "ERROR \n"; print_r($err,true); exit(); } echo $response;