Source for file test_ManipulateModelMDB.php
Documentation is available at test_ManipulateModelMDB.php
// ----------------------------------------------------------------------------------
// PHP Script: test_ManipulatingModel_MDB.php
// ----------------------------------------------------------------------------------
* This is an online demo of RAP's database backend.
* This script demonstrates some methods to manipulate a Model_MDB.
* @author Radoslaw Oldakowski <radol@gmx.de>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Test Store Models in Database</title>
require_once 'RDF/Store/MDB.php';
require_once 'RDF/Model/MDB.php';
require_once 'RDF/Model/Memory.php';
// # 1. Connect to MsAccess database (via ODBC)
// # ------------------------------------------
// Connect to MsAccess (rdf_db DSN) database using connection settings
// defined in constants.php :
'username' => 'metapear',
'hostspec' => 'localhost',
$Model_MDB = $rdf_database->getModel ("Example1.rdf");
// Output the model as HTML table
$Model_MDB->writeAsHtmlTable ();
// # 3. Add a statement tho the Model_MDB
// # ----------------------------------
// Add the statement to the Model_MDB
$Model_MDB->add ($statement);
// Output the string serialization of the Model_MDB
echo $Model_MDB->toStringIncludingTriples ();
// # 4. Search statements
// # ---------------------
// Search for statements having object $literal
$res = $Model_MDB->find (null , null , $literal);
$res->writeAsHtmlTable ();
// # 5. 5. Replace nodes and serialize the Model_MDB to XML/RDF
// # --------------------------------------------------------
$Model_MDB->replace (null , null ,
$Model_MDB->writeAsHtml ();
// # 6. Remove a statement
// # ---------------------
$Model_MDB->writeAsHtmlTable ();
// # 7. Generate a Model_Memory and compare both models
// # ----------------------------------------------
// Generate a Model_Memory
$Model_Memory = $Model_MDB->getMemModel ();
// Compare this Model_MDB withe the generated Model_Memory
$res = $Model_MDB->equals ($Model_Memory);
echo "models are different";
// # 8. Save Model_MDB to file
// # ----------------------------------------------
// Save Model_MDB to file (XML/RDF)
$Model_MDB->saveAs ("Output.rdf");
// Save Model_MDB to file (N3)
$Model_MDB->saveAs ("Output.n3");
Documentation generated on Mon, 11 Mar 2019 15:39:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|