Source for file MDB.php
Documentation is available at MDB.php 
// ----------------------------------------------------------------------------------  
// ----------------------------------------------------------------------------------  
 * Store_MDB is a persistent store of RDF data using relational database technology.  
 * Store_MDB uses the MDB Library for PHP (http://pear.php.net/MDB),  
 * which allows to connect to multiple databases in a portable manner.  
 * @author Radoslaw Oldakowski <radol@gmx.de>  
     * Database connection object  
     * @var object ADOConnection   
     * Set the database connection with the given parameters.  
        // create a new connection object  
        $this->dbConn = & MDB ::connect ($dsn, $options);   
     * Create tables and indexes for the given database type.  
     * @param string $filename   
        MDB ::loadFile ('Manager');  
        $manager = & new MDB_Manager;   
        $err =  $manager->connect ($this->dbConn);   
        if(PEAR ::isError ($err)) {  
        $err =  $manager->updateDatabase (  
            array ('database' =>  $this->dbConn->database_name ) 
        if(PEAR ::isError ($err)) {  
        $dsn =  $this->dbConn->getDSN ();   
        // cant we remove this ugly hack?  
        if (isset ($dsn['phptype']) &&  $dsn['phptype'] ==  'mysql') {  
            $this->dbConn->query ('CREATE INDEX s_mod_idx ON statements (modelID)');   
            $sql =  'CREATE INDEX s_sub_pred_idx ON statements (subject(200),predicate(200))';   
            $this->dbConn->query ('CREATE INDEX s_obj_idx ON statements (object(250))');   
     * List all Model_MDBs stored in the database.  
        $sql =  'SELECT modelURI, baseURI FROM models';   
        return $this->dbConn->queryAll ($sql, MDB_FETCHMODE_ASSOC );   
     * Check if the Model_MDB with the given modelURI is already stored in the database  
     * @param string $modelURI   
            WHERE modelURI = ' .  $this->dbConn->getValue ('text', $modelURI);   
        $result =  $this->dbConn->queryOne ($sql);   
        if (PEAR ::isError ($result)) {  
     * Create a new instance of Model_MDB with the given $modelURI and  
     * load the corresponding values of modelID and baseURI from the database.  
     * Return FALSE if the Model_MDB does not exist.  
     * @param string $modelURI   
     * @return object Model_MDB   
        $sql =  'SELECT modelURI, modelID, baseURI FROM models  
            WHERE modelURI=' .  $this->dbConn->getValue ('text', $modelURI);   
        $modelVars =  $this->dbConn->queryRow ($sql);   
            $modelVars[1 ], $modelVars[2 ]);   
     * Create a new instance of Model_MDB with the given $modelURI  
     * and insert the Model_MDB variables into the database.  
     * Return FALSE if there is already a model with the given URI.  
     * @param string $modelURI   
     * @return object Model_MDB   
        $this->dbConn->autoCommit (false );   
        $sql =  'INSERT INTO models VALUES (' .   
            $this->dbConn->getValue ('text', $modelID) . ',' .   
            $this->dbConn->getValue ('text', $modelURI) . ',' .   
            $this->dbConn->getValue ('text', $baseURI) . ')';   
        $result = & $this->dbConn->query ($sql);   
        $this->dbConn->autoCommit (true );   
        if (PEAR ::isError ($result)) {  
     * Store a Model_Memory or another Model_MDB from a different Store_MDB in the database.  
     * Return FALSE if there is already a model with modelURI matching the modelURI  
     * @param object Model  &$model   
     * @param string $modelURI   
    function putModel(&$model, $modelURI = null )  
            if (is_a($model, 'RDF_Model_Memory')) {  
                $modelURI =  $model->modelURI;   
        $newmodel =  $this->getNewModel($modelURI, $model->getBaseURI ());   
        return $newmodel->addModel ($model);   
     * !!! Warning: If you close the Store_MDB all active instances of Model_MDB from this  
     * !!!          Store_MDB will lose their database connection !!!  
    // =============================================================================  
    // **************************** protected methods ********************************  
    // =============================================================================  
     * Create a unique ID for the Model_MDB to be insert into the models table.  
     * This method was implemented because some databases do not support auto-increment.  
        $sql =  'SELECT MAX(modelID) FROM models';   
        $maxModelID =  $this->dbConn->queryOne ($sql);   
} // end: Class Store_MDB  
 
 
        
		    
 
		    Documentation generated on Mon, 11 Mar 2019 15:39:28 -0400 by  phpDocumentor 1.4.4. PEAR Logo Copyright ©  PHP Group 2004.
	        
       |