PHP code example of saft / saft-wordpress
1. Go to this page and download the library: Download saft/saft-wordpress 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/ */
saft / saft-wordpress example snippets
function foo()
{
// important, to make $saftdb know inside the function
global $saftdb;
// create test graph inside the store
$testGraph = new NamedNodeImpl('http://foo/');
$saftdb->createGraph($testGraph);
// test triple, create it only in the memory
$subject = new NamedNodeImpl('http://saft/testtriple/s');
$predicate = new NamedNodeImpl('http://saft/testtriple/p');
$object = new NamedNodeImpl('http://saft/testtriple/o');
$triple = new StatementImpl($subject, $predicate, $object);
// add test triple to store
$saftdb->addStatements(array($triple), $testGraph);
// query our test graph to ask for a list of all triples
$result = $saftdb->query('SELECT * FROM <'. $testGraph->getUri() .'> WHERE {?s ?p ?o.}');
var_dump($result);
}