src/acdhOeaw/fedora/SparqlClient.php
public function query(string $query, int $nTries = 1): Result {
        $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
        $body    = 'query=' . rawurlencode($query);
        $request = new Request('POST', $this->url, $headers, $body);
        while ($nTries > 0) {
            $nTries--;
            try {
                $response = $this->client->send($request);
                $body     = $response->getBody();
                $result   = new Result($body, 'application/sparql-results+json');
                break;
            } catch (RequestException $ex) {
                if ($nTries <= 0) {
                    throw $ex;
                }
            }
        }
        return $result;
    }
public function query(string $query, int $nTries = 1): Result {
        $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
        $body    = 'query=' . rawurlencode($query);
        $request = new Request('POST', $this->url, $headers, $body);
        while ($nTries > 0) {
            $nTries--;
            try {
                $response = $this->client->send($request);
                $body     = $response->getBody();
                $result   = new Result($body, 'application/sparql-results+json');
                break;
            } catch (RequestException $ex) {
                if ($nTries <= 0) {
                    throw $ex;
                }
            }
        }
        return $result;
    }
public function query ( string $ query , int $ nTries = 1 ) : Result { $ headers = array ( 'Content-Type' => 'application/x-www-form-urlencoded' ) ; $ body = 'query=' . rawurlencode ( $ query ) ; $ request = new Request ( 'POST' , $ this -> url , $ headers , $ body ) ; while ( $ nTries > 0 ) { $ nTries -- ; try { $ response = $ this -> client -> send ( $ request ) ; $ body = $ response -> getBody ( ) ; $ result = new Result ( $ body , 'application/sparql-results+json' ) ; break ; } catch ( RequestException $ ex ) { if ( $ nTries <= 0 ) { throw $ ex ; } } } return $ result ; }
Runs a given query.

There is no support for UPDATE queries.

@param string $query SPARQL query to be run
@param int $nTries how many times request should be repeated in case of
error before giving up
@return \EasyRdf\Sparql\Result
Runs a given query .