Пример #1
0
 /**
  *
  */
 function loadModel($url)
 {
     // load model from file
     if ($url) {
         $this->m = new MemModel();
         $this->m->load($url);
     } else {
         $db = new DbStore(PUBBY_DB_DRIVER, PUBBY_DB_HOST, PUBBY_DB_DB, PUBBY_DB_USER, PUBBY_DB_PASS);
         $this->m = $db->getModel(PUBBY_DBMODEL);
     }
 }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Test Store Models in Database</title>
</head>
<body>

<?php 
// Include RAP
define("RDFAPI_INCLUDE_DIR", "./../api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
## 1. Connect to MsAccess database (via ODBC)
## ------------------------------------------
// Connect to MsAccess (rdf_db DSN) database using connection settings
// defined in constants.php :
$rdf_database = new DbStore();
## 2. Store a memory model in database.
## ------------------------------------
// Load an RDF-Documtent into a memory model
// Filename of an RDF document
$base = "example1.rdf";
// Create a new memory model
$memModel = new MemModel();
// Load and parse document
$memModel->load($base);
// Now store the model in database
// An unique modelURI will be generated
$rdf_database->putModel($memModel);
// You can also provide an URI for the model to be stored
$modelURI = "example1.rdf";
// But then you must check if there already is a model with the same modelURI
Пример #3
0
if ($model == NULL) {
    // Didn't get modelID from URL rewriting
    header('HTTP/1.0 500 Internal Server Error');
    echo "500 - Didn't get modelURI from URL rewriting.\n";
    return;
}
$modelId = $modelmap[$model];
if ($modelId == NULL) {
    // Didn't get modelID from URL rewriting
    header('HTTP/1.0 404 Not Found');
    echo "404 - Model " . $model . " not found";
    return;
} elseif (substr($modelId, 0, 3) == "db:") {
    // Database backed model
    $modelURI = substr($modelId, 3);
    $database = new DbStore($NETAPI_DB_DRIVER, $NETAPI_DB_HOST, $NETAPI_DB_DB, $NETAPI_DB_USER, $NETAPI_DB_PASS);
    $type = 'model';
    if ($database->modelExists($modelURI) == False) {
        $type = 'dataset';
        if ($database->datasetExists($modelURI) == False) {
            // Model not found in the database
            header('HTTP/1.0 404 Not Found');
            echo "404 - Model " . $model . " not found\n";
            return;
        }
    }
    if ($type == 'model') {
        $model1 = $database->getModel($modelURI);
    } else {
        $model1 = $database->getDatasetDb($modelURI);
    }
Пример #4
0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Test Store Models in Database</title>
</head>
<body>

<?php 
// Include RAP
require_once 'config.php';
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
## 1. Connect to MsAccess database (via ODBC)
## ------------------------------------------
// Connect to MsAccess (rdf_db DSN) database using connection settings
// defined in constants.php :
$rdf_database = new DbStore();
$rdf_database->createTables(ADODB_DB_DRIVER);
## 2. Store a memory model in database.
## ------------------------------------
// Load an RDF-Documtent into a memory model
// Filename of an RDF document
$base = "example1.rdf";
// Create a new memory model
$memModel = new MemModel();
// Load and parse document
$memModel->load($base);
// Now store the model in database
// An unique modelURI will be generated
$rdf_database->putModel($memModel);
// You can also provide an URI for the model to be stored
$modelURI = "example1.rdf";
<?php 
// Include RAP
define("RDFAPI_INCLUDE_DIR", "./../api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
## 1. Connect to MsAccess database (via ODBC) and create tables.
// Connect to MsAccess (rdf_db DSN) database using connection settings
// defined in constants.php :
// ----------------------------------------------------------------------------------
// Database
// ----------------------------------------------------------------------------------
// define("ADODB_DB_DRIVER", "odbc");
// define("ADODB_DB_HOST", "rdf_db");
// define("ADODB_DB_NAME", "");
// define("ADODB_DB_USER", "");
// define("ADODB_DB_PASSWORD", "");
$rdf_database = new DbStore();
// Create tables for MsAccess
$rdf_database->createTables('MsAccess');
## 2. Connect to MySQL database and create tables.
/*
// Connect to MySQL database with user defined connection settings
$rdf_database = new DbStore('MySQL', 'localhost', 'db_name', 'user_name', 'password' );

// Create tables for MySQL
$rdf_database->createTables('MySQL');
*/
## 3. Connect to other databases
/*
// Example:
// Connect to Oracle database with user defined connection settings
$rdf_database = new DbStore('Oracle', FALSE, 'db_name', 'username', 'password' );
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Test Store Models in Database</title>
</head>
<body>

<?php 
// Include RAP
define("RDFAPI_INCLUDE_DIR", "./../api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
## 1. Connect to MsAccess database (via ODBC)
## ------------------------------------------
// Connect to MsAccess (rdf_db DSN) database using connection settings
// defined in constants.php :
$rdf_database = new DbStore();
## 2. Load a DbModel
## -----------------
$dbModel = $rdf_database->getModel("example1.rdf");
// Output the model as HTML table
$dbModel->writeAsHtmlTable();
echo "<br><br>";
## 3. Add a statement tho the DbModel
## ----------------------------------
// Ceate a new statement
$statement = new Statement(new Resource("http://www.w3.org/Home/Lassila"), new Resource("http://description.org/schema/Description"), new Literal("Lassilas persönliche Homepage", "de"));
// Add the statement to the DbModel
$dbModel->add($statement);
// Output the string serialization of the DbModel
echo $dbModel->toStringIncludingTriples();
echo "<br><br>";
Пример #7
0
<?php

/**
* Prepares your system for RAP.
* Creates database tables if they don't exist yet
*/
$strConfFile = dirname(__FILE__) . '/config.php';
if (!file_exists($strConfFile)) {
    die('Please copy "test/config.php.dist" to "test/config.php" and adjust it');
}
require_once $strConfFile;
require_once RDFAPI_INCLUDE_DIR . '/model/DbStore.php';
require_once RDFAPI_INCLUDE_DIR . '/model/ModelFactory.php';
try {
    $type = DbStore::getDriver($GLOBALS['dbConf']['type']);
    DbStore::assertDriverSupported($type);
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "Be sure to write the driver type in the same cAsE\n";
    exit(4);
}
try {
    $database = ModelFactory::getDbStore($GLOBALS['dbConf']['type'], $GLOBALS['dbConf']['host'], $GLOBALS['dbConf']['database'], $GLOBALS['dbConf']['user'], $GLOBALS['dbConf']['password']);
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "Maybe the database '" . $GLOBALS['dbConf']['database'] . "' does not exist?\n";
    exit(3);
}
if ($database->isSetup()) {
    echo "Database is already setup.\n";
    exit(0);