Skip to content
cweiske edited this page Mar 16, 2012 · 1 revision

Import from String

Load the data:

$parser = new Erfurt_Syntax_RdfParser();
$parser->initializeWithFormat('n3');
$arData = $parser->parse(
    $rdf,
    Erfurt_Syntax_RdfParser::LOCATOR_DATASTRING
);

Store this data in the store:

$store = Erfurt_App::getInstance()->getStore();
$model = $store->getModel('http://uri/of/my/graph');
$model->addMultipleStatements($arData);

You may want to create the model first in case it does not exist yet, or you want to clean previous data:

try {
    $store->deleteModel('http://uri/of/my/graph');
} catch (Exception $e) {/* ignore deletion failure */}
$model = $store->getNewModel('http://uri/of/my/graph');
Clone this wiki locally