#!/usr/bin/php setEndpointQuery($endpointQueryOnly); $ENDPOINT->setEndpointUpdate($endpointUpdateOnly); $ENDPOINT->setNameParameterQueryRead($nameParameterQuery); $ENDPOINT->setNameParameterQueryWrite($nameParameterUpdate); } if($endpointLogin != "" && $endpointPassword != ""){ $ENDPOINT->setLogin($endpointLogin); $ENDPOINT->setPassword($endpointPassword); } switch($typeOutput){ case "txt": $type = "text/plain"; break; 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 "table": 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 login : ".$ENDPOINT->getLogin()." - Endpoint password : ".$ENDPOINT->getPassword()." "; } ///////// $ENDPOINT->ResetErrors(); //queryRead /* */ if($typeOutput === "table"){ $rows = $ENDPOINT->query( file_get_contents($filename), 'rows'); $err = $ENDPOINT->getErrors(); if ($err) { echo "ERROR \n"; print_r($err,true); exit(1); } 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"; } }else{ 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(1); } $err = $ENDPOINT->getErrors(); if ($err) { echo "ERROR \n"; print_r($err,true); exit(1); } echo $response; }