Example #1
0
 /**
  * Convert an MDB result to a memory Model.
  *
  * Every successful database query returns an MDB result
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  * !!! This method can only be applied to a result with row arrays
  * !!! containing a representation of the database table: statements,
  * !!! with an index corresponding to following table columns:
  * !!! [0] - subject, [1] - predicate, [2] - object, [3] - l_language,
  * !!! [4] - l_datatype, [5] - subject_is, [6] - object_is
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  *
  * @param ressource MDB Result
  * @return object Model_Memory
  * @access private
  */
 function _convertRecordSetToMemModel($result)
 {
     $res =& new RDF_Model_Memory($this->getBaseURI());
     while (is_array($row = $this->dbConn->fetchInto($result))) {
         // subject
         if ($row[5] == 'r') {
             $sub =& RDF_Resource::factory($row[0]);
         } else {
             $sub =& RDF_BlankNode::factory($row[0]);
         }
         // predicate
         $pred =& RDF_Resource::factory($row[1]);
         // object
         if ($row[6] == 'r') {
             $obj =& RDF_Resource::factory($row[2]);
         } elseif ($row[6] == 'b') {
             $obj =& RDF_BlankNode::factory($row[2]);
         } else {
             $obj =& RDF_Literal::factory($row[2], $row[3]);
             if ($row[4]) {
                 $obj->setDatatype($row[4]);
             }
         }
         $statement =& RDF_Statement::factory($sub, $pred, $obj);
         $res->add($statement);
     }
     $this->dbConn->freeResult($result);
     return $res;
 }
Example #2
0
 /**
  * Adds a new statement to the model
  * This method is called by generateModel().
  *
  * @access private
  * @param string &$user_data
  * @param string $subject_type
  * @param string $subject
  * @param string $predicate
  * @param string $ordinal
  * @param string $object_type
  * @param string $object
  * @param string $xml_lang )
  * @return object Model_Memory
  */
 function add_statement_to_model(&$user_data, $subject_type, $subject, $predicate, $ordinal, $object_type, $object, $xml_lang, $datatype)
 {
     // create subject
     if ($subject_type == RDF_SUBJECT_TYPE_BNODE) {
         $objsub =& RDF_BlankNode::factory($subject);
     } else {
         $objsub =& RDF_Resource::factory($subject);
     }
     // create predicate
     $objpred =& RDF_Resource::factory($predicate);
     // create object
     if ($object_type == RDF_OBJECT_TYPE_RESOURCE || $object_type == RDF_OBJECT_TYPE_BNODE) {
         if ($object_type == RDF_OBJECT_TYPE_BNODE) {
             $objobj =& RDF_BlankNode::factory($object);
         } else {
             $objobj =& RDF_Resource::factory($object);
         }
     } else {
         $objobj =& RDF_Literal::factory($object);
         if ($datatype != '') {
             $objobj->setDatatype($datatype);
         } elseif ($xml_lang != "") {
             $objobj->setLanguage($xml_lang);
         }
     }
     // create statement
     $statement =& RDF_Statement::factory($objsub, $objpred, $objobj);
     // add statement to model
     $this->model->add($statement);
 }