PHP code example of benestar / asparagus
1. Go to this page and download the library: Download benestar/asparagus library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
benestar / asparagus example snippets
use Asparagus\QueryBuilder;
$prefixes = array(
'test' => 'http://www.example.com/test#'
);
$queryBuilder = new QueryBuilder( $prefixes );
$queryBuilder->select( '?name', '?email' )
->where( '?person', 'test:name', '?name' )
->also( 'test:email', '?email' )
->limit( 10 );
echo $queryBuilder->format();
use Asparagus\QueryBuilder;
$prefixes = array(
'test' => 'http://www.example.com/test#'
);
$queryBuilder = new QueryBuilder( $prefixes );
$queryBuilder->select( '?name' )
->where( '?person', 'test:name', '?name' )
->optional( '?person', 'test:email', '?email' )
->filter( '!BOUND (?email)' );
echo $queryBuilder->format();
use Asparagus\QueryBuilder;
$prefixes = array(
'dc10' => 'http://purl.org/dc/elements/1.0/',
'dc11' => 'http://purl.org/dc/elements/1.1/'
);
$queryBuilder = new QueryBuilder( $prefixes );
$queryBuilder->select( '?title', '?author' )
->union(
$queryBuilder->newSubgraph()
->where( '?book', 'dc10:title', '?title' )
->also( 'dc10:creator', '?author' ),
$queryBuilder->newSubgraph()
->where( '?book', 'dc11:title', '?title' )
->also( 'dc11:creator', '?author' )
);
echo $queryBuilder->format();
sparql
PREFIX dc10: <http://purl.org/dc/elements/1.0/>
PREFIX dc11: <http://purl.org/dc/elements/1.1/>
SELECT ?title ?author WHERE {
{
?book dc10:title ?title ;
dc10:creator ?author .
} UNION {
?book dc11:title ?title ;
dc11:creator ?author .
}
}