示例#1
0
 /**
  * Sends a query over the RAP API
  * 
  * @param String @query Query to be send
  * @return Array @result RAP Result set
  * 
  */
 function doQueryRAP($query)
 {
     $GLOBALS['dbConf']['type'] = 'MySQL';
     $GLOBALS['dbConf']['host'] = $this->options["host"];
     $GLOBALS['dbConf']['database'] = $this->options["db"];
     $GLOBALS['dbConf']['user'] = $this->options["user"];
     $GLOBALS['dbConf']['password'] = $this->options["pass"];
     $database = ModelFactory::getDbStore($GLOBALS['dbConf']['type'], $GLOBALS['dbConf']['host'], $GLOBALS['dbConf']['database'], $GLOBALS['dbConf']['user'], $GLOBALS['dbConf']['password']);
     $dbModel = $database->getModel($this->options["model"]);
     $result = $dbModel->sparqlQuery($query);
     #var_dump($result);
     return $result;
 }
示例#2
0
 /**
  * Returns a DbModel with the database connection 
  * defined in constants.php.
  * You can supply a base URI. If a model with the given base 
  * URI exists in the DbStore, it'll be opened. 
  * If not, a new model will be created.
  *
  * @param   string  $baseURI
  * @return	object	DbModel
  * @access	public
  */
 function &getDefaultDbModel($baseURI = null)
 {
     $dbStore = ModelFactory::getDbStore();
     return ModelFactory::getDbModel($dbStore, $baseURI);
 }
示例#3
0
<?php

require_once '../../parser/rdf/rap/test/config.php';
$database = ModelFactory::getDbStore($GLOBALS['dbConf']['type'], $GLOBALS['dbConf']['host'], $GLOBALS['dbConf']['database'], $GLOBALS['dbConf']['user'], $GLOBALS['dbConf']['password']);
$strModel = "http://xmlns.com/foaf/0.1/";
$dbModel = $database->getModel($strModel);
if ($dbModel === false) {
    die('Database does not have a model ' . $strModel . "\n");
}
示例#4
0
// loomp vocabulary class
require_once LIBRARY_PATH . '/loomp-backend/LOOMP_C.php';
// load loomp api
require_once LIBRARY_PATH . '/loomp-backend/api.php';
require_once LIBRARY_PATH . '/loomp-backend/search.php';
define('BASE_URL', $configuration->server->path);
define('LOOMP_HOST', $configuration->server->host);
define('LOOMP_BASE_PATH', $configuration->loomp->base);
// Loomp URIs
define("LOOMP_MODEL_URI", LOOMP_BASE_PATH . "/loomp/dbModel/");
define("LOOMP_USER_URI_NS", LOOMP_BASE_PATH . "/users/");
if (!strstr($_SERVER['REQUEST_URI'], 'install') && !strstr($_SERVER['REQUEST_URI'], 'error')) {
    try {
        // set database connection and retrieve the rdf model
        $logger->debug("Initializing RDF store");
        $rdfStore = ModelFactory::getDbStore($configuration->loomp->db->type, $configuration->loomp->db->host, $configuration->loomp->db->name, $configuration->loomp->db->user, $configuration->loomp->db->pass);
        //die(LOOMP_MODEL_URI);
        $registry->rdfModel = $rdfStore->getModel(LOOMP_MODEL_URI);
        if ($registry->rdfModel === false) {
            throw new Exception("Failed to initialize RDF store.");
        }
        $logger->debug("Initializing Loomp API");
        $registry->loompApi = new LoompApi();
        // Active Record stuff
        require_once RDFAPI_INCLUDE_DIR . 'util/adodb/adodb-active-record.inc.php';
        require_once APPLICATION_PATH . '/model/User.php';
        require_once APPLICATION_PATH . '/model/Access.php';
        ADOdb_Active_Record::SetDatabaseAdapter($rdfStore->getDbConn());
    } catch (Exception $e) {
        $logger->err("Init error: " . $e->getMessage());
        $logger->err($e->getTraceAsString());
<?php

// Only show serious errors.
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_time_limit(99999);
ini_set('memory_limit', -1);
echo 'Memory Limit is: ' . ini_get('memory_limit') . "\n";
echo "Test 1\n";
//error_reporting(E_ALL);
require_once 'rdfapi-php/test/config.php';
include RDFAPI_INCLUDE_DIR . "RDFAPI.php";
$database = ModelFactory::getDbStore('MySQL', 'localhost', 'rap', 'root', '');
echo "Connected to DBStore.\n";
//$datatbase->createTables("MySQL");
echo "Tables created.\n";
//$friends = $datatbase->getNewModel("http://foo");
$friends = $database->getModel("http://foo");
// Create a new MemModel and load the document
//$friends = ModelFactory::getDefaultModel();
echo "Have model, Loading data...\n";
$friends->load('C:/work/services/Teaching/xampp/htdocs/RAP/dbpedia_10000aa.nt');
echo "Loaded.\n";
//$friends->load('C:/work/services/Teaching/xampp/htdocs/foaf/foaf.rdf');
$querystring = '
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?x ?name
WHERE { ?x foaf:name ?name }
';
$result = $friends->sparqlQuery($querystring);
echo "Executed Query.\n";
error_reporting(E_ALL);
示例#6
0
 /**	
  * @return direct connection to the underlying database
  * @access protected	
  */
 protected function getDbConnection()
 {
     $dbConfig = Zend_Registry::getInstance()->configuration->loomp->db;
     $dbStore = ModelFactory::getDbStore($dbConfig->type, $dbConfig->host, $dbConfig->name, $dbConfig->user, $dbConfig->pass);
     return $dbStore->getDbConnection();
 }
示例#7
0
 /**
  *   Instantiates the database object and clears
  *   any existing statements to have a fresh place
  *   for a unit test.
  *
  *   @return array       array($database, $dbModel)
  */
 protected function prepareDatabase()
 {
     $database = ModelFactory::getDbStore($GLOBALS['dbConf']['type'], $GLOBALS['dbConf']['host'], $GLOBALS['dbConf']['database'], $GLOBALS['dbConf']['user'], $GLOBALS['dbConf']['password']);
     if ($database->modelExists(self::$strModelUri)) {
         //need to remove model
         $database->removeNamedGraphDb(self::$strModelUri);
     }
     $dbModel = $database->getNewModel(self::$strModelUri);
     if (!$dbModel instanceof DbModel) {
         throw new Exception('Error creating new model for SparqlEngineDb tests: ' . $dbModel);
     }
     return array($database, $dbModel);
 }