model
[ class tree: model ] [ index: model ] [ all elements ]

Class: RDF_Model_MDB

Source Location: /RDF-0.2.0/RDF/Model/MDB.php

Class Overview

RDF_Object
   |
   --RDF_Model
      |
      --RDF_Model_MDB

A model is a programming interface to an RDF graph.


Author(s):

Version:

  • V0.7

Variables

Methods


Inherited Variables

Inherited Methods

Class: RDF_Model

RDF_Model::getBaseURI()
Return current baseURI.
RDF_Model::load()
Load a model from a file containing RDF, N3 or N-Triples.
RDF_Model::_addStatementFromAnotherModel()
Adds a statement from another model to this model.

Class: RDF_Object

RDF_Object::factory()
RDF_Object::toString()
Serializes a object into a string

Class Details

[line 17]
A model is a programming interface to an RDF graph.

An RDF graph is a directed labeled graph, as described in http://www.w3.org/TR/rdf-mt/. It can be defined as a set of <S, P, O> triples, where P is a uriref, S is either a uriref or a blank node, and O is either a uriref, a blank node, or a literal.



[ Top ]


Class Variables

$dbConn =

[line 25]

Database connection object
  • Var: driver instance
  • Access: protected

Type:   object MDB


[ Top ]

$modelID =

[line 43]

Database internal modelID.

Used to avoid JOINs.

  • Access: protected

Type:   string


[ Top ]

$modelURI =

[line 34]

Unique model URI.

Used to identify the Model_MDB.

  • Access: protected

Type:   string


[ Top ]



Method Detail

RDF_Model_MDB (Constructor)   [line 55]

RDF_Model_MDB RDF_Model_MDB( object MDB &$dbConnection, string $modelURI, string $modelID, [string $baseURI = null])

Do not call this directly.

Use the method getModel,getNewModel or putModel of the Class Store_MDB instead.

  • Access: public

Parameters:

string   $modelURI   — 
string   $modelID   — 
string   $baseURI   — 
object MDB   &$dbConnection   —  driver instance &$dbConnection

[ Top ]

add   [line 115]

void add( object Statement &$statement)

Add a new triple to this Model_MDB.
  • Access: public

Parameters:

object Statement   &$statement   — 

[ Top ]

addModel   [line 721]

void addModel( &$model, object Model $model)

Add the given model to this Model_MDB.

This function monitors for SQL errors, and will commit if no errors have occured, otherwise it will rollback. If any statement of the model to be added to this model contains a blankNode with an identifier already existing in this model, a new blankNode is generated.

  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

close   [line 799]

void close( )

Close this Model_MDB
  • Access: public

[ Top ]

contains   [line 270]

boolean contains( object Statement &$statement)

Check if the Model_MDB contains the given statement
  • Access: public

Parameters:

object Statement   &$statement   — 

[ Top ]

containsAll   [line 292]

boolean containsAll( object Model &$model)

Determine if all of the statements in the given model are also contained in this Model_MDB.
  • Access: public

Parameters:

object Model   &$model   — 

[ Top ]

containsAny   [line 325]

boolean containsAny( object Model &$model)

Determine if any of the statements in the given model are also contained in this Model_MDB.
  • Access: public

Parameters:

object Model   &$model   — 

[ Top ]

delete   [line 776]

void delete( )

Remove this Model_MDB from database and clean up.

This function monitors for SQL errors, and will commit if no errors have occured, otherwise it will rollback.

  • Throws: SqlError
  • Access: public

[ Top ]

equals   [line 593]

boolean equals( object model &$that)

Check if two models are equal.

Two models are equal if and only if the two RDF graphs they represent are isomorphic.

Warning: This method doesn't work correct with models where the same blank node has different identifiers in the two models. We will correct this in a future version.

  • Throws: PhpError
  • Access: public

Parameters:

object model   &$that   — 

[ Top ]

find   [line 365]

object Model_Memory find( object Resource $subject, object Resource $predicate, object Node $object)

General method to search for triples in the Model_MDB.

null input for any parameter will match anything. Example: $result = $m->find( null, null, $node ); Finds all triples with $node as object.

  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

object Resource   $subject   — 
object Resource   $predicate   — 
object Node   $object   — 

[ Top ]

findCount   [line 499]

integer findCount( object Resource $subject, object Resource $predicate, object Node $object)

Search for triples and return the number of matches.

null input for any parameter will match anything.

  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

object Resource   $subject   — 
object Resource   $predicate   — 
object Node   $object   — 

[ Top ]

findFirstMatchingStatement   [line 458]

object Statement findFirstMatchingStatement( object Resource $subject, object Resource $predicate, object Node $object)

Search for triples and return the first matching statement.

null input for any parameter will match anything. Return an null if nothing is found.

  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

object Resource   $subject   — 
object Resource   $predicate   — 
object Node   $object   — 

[ Top ]

findRegex   [line 410]

object Model_Memory findRegex( string $subject_regex, string $predicate_regex, string $object_regex)

Method to search for triples using Perl-style regular expressions.

null input for any parameter will match anything. Example: $result = $m->find_regex( null, null, $regex ); Finds all triples where the label of the object node matches the regular expression. Return an empty Model_Memory if nothing is found. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING: Mhis method loads a Model_MDB into memory and performs the search on a Model_Memory, which can be slow with large models. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

string   $subject_regex   — 
string   $predicate_regex   — 
string   $object_regex   — 

[ Top ]

findVocabulary   [line 429]

object Model_Memory findVocabulary( string $vocabulary)

Return all tripels of a certain vocabulary.

$vocabulary is the namespace of the vocabulary inluding a # : / char at the end. e.g. http://www.w3.org/2000/01/rdf-schema# Return an empty model if nothing is found.

  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

string   $vocabulary   — 

[ Top ]

getMemModel   [line 204]

object Model_Memory &getMemModel( )

Create a Model_Memory containing all the triples of the current Model_MDB
  • Access: public

[ Top ]

getUniqueResourceURI   [line 814]

string getUniqueResourceURI( string $prefix)

Internal method, that returns a resource URI that is unique for the Model_MDB.

URIs are generated using the base_uri of the Model_MDB, the prefix and a unique number.

  • Access: protected

Parameters:

string   $prefix   — 

[ Top ]

intersect   [line 694]

object Model_Memory &intersect( &$model, object Model $model)

Return a new Model_Memory containing all the statements which are in both this model and the given model.
  • Throws: PhpError
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

isEmpty   [line 101]

boolean isEmpty( )

Check if this Model_MDB is empty
  • Access: public

[ Top ]

reify   [line 762]

object Model_Memory &reify( )

Reify the Model_MDB.

Return a new Model_Memory that contains the reifications of all statements of this Model_MDB.

  • Access: public

[ Top ]

remove   [line 159]

void remove( object Statement &$statement)

Remove the given triple from this Model_MDB.
  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

object Statement   &$statement   — 

[ Top ]

replace   [line 534]

void replace( object Resource $subject, object Resource $predicate, object Node $object, object Node $replacement)

General method to replace nodes of a Model_MDB.

null input for any parameter will match nothing. Example: $m->replace($resource, null, $node, $replacement); Replaces all $node objects beeing subject or object in any triple of the model with the $replacement node. Throw an error in case of a paramter mismatch.

  • Throws: SqlError
  • Throws: PhpError
  • Access: public

Parameters:

object Resource   $subject   — 
object Resource   $predicate   — 
object Node   $object   — 
object Node   $replacement   — 

[ Top ]

saveAs   [line 257]

boolean saveAs( string $filename, [string $type = 'rdf'])

Saves the RDF,N3 or N-Triple serialization of the Model_MDB to a file.

You can decide to which format the model should be serialized by using a corresponding suffix-string as $type parameter. If no $type parameter is placed this method will serialize the model to XML/RDF format. Returns FALSE if the Model_MDB couldn't be saved to the file.

  • Access: public

Parameters:

string   $filename   — 
string   $type   — 

[ Top ]

setBaseURI   [line 71]

void setBaseURI( string $uri)

Set a base URI for the Model_MDB.

Affects creating of new resources and serialization syntax.

  • Throws: SqlError
  • Access: public

Parameters:

string   $uri   — 

[ Top ]

size   [line 87]

integer size( )

Return the number of statements in this Model_MDB
  • Access: public

[ Top ]

subtract   [line 667]

object Model_Memory &subtract( &$model, object Model $model)

Return a new Model_Memory that is the subtraction of another model from this Model_MDB.
  • Throws: PhpError
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

toString   [line 180]

string toString( )

Short dump of the Model_MDB.
  • Access: public

Overrides RDF_Object::toString() (Serializes a object into a string)
[ Top ]

toStringIncludingTriples   [line 192]

string toStringIncludingTriples( )

Dump of the Model_MDB including all triples.
  • Access: public

[ Top ]

unite   [line 640]

object Model_Memory &unite( &$model, object Model $model)

Return a new Model_Memory that is the set-union the model with another model.

The result of taking the set-union of two or more RDF graphs (i.e. sets of triples) is another graph, which we will call the merge of the graphs. Each of the original graphs is a subgraph of the merged graph. Notice that when forming a merged graph, two occurrences of a given uriref or literal as nodes in two different graphs become a single node in the union graph (since by definition they are the same uriref or literal) but blank nodes are not 'merged' in this way; and arcs are of course never merged. In particular, this means that every blank node in a merged graph can be identified as coming from one particular graph in the original set of graphs.

Notice that one does not, in general, obtain the merge of a set of graphs by concatenating their corresponding N-triples documents and constructing the graph described by the merged document, since if some of the documents use the same node identifiers, the merged document will describe a graph in which some of the blank nodes have been 'accidentally' merged. To merge Ntriples documents it is necessary to check if the same nodeID is used in two or more documents, and to replace it with a distinct nodeID in each of them, before merging the documents. (Not implemented yet !!!!!!!!!!!)

  • Throws: PhpError
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

writeAsHtml   [line 215]

void writeAsHtml( )

Write the RDF serialization of the _Model_MDB as HTML.
  • Access: public

[ Top ]

writeAsHtmlTable   [line 226]

void writeAsHtmlTable( )

Write the RDF serialization of the Model_MDB as HTML table.
  • Access: public

[ Top ]

writeRDFToString   [line 238]

string writeRDFToString( )

Write the RDF serialization of the Model_MDB to string
  • Access: public

[ Top ]

_checkBaseURI   [line 846]

string _checkBaseURI( string $uri)

If the URI doesn't end with # : or /, then a # is added to the URI.

Used at setting the baseURI of this Model_MDB.

  • Access: protected

Parameters:

string   $uri   — 

[ Top ]

_containsRow   [line 1008]

boolean _containsRow( array $row)

Check if this Model_MDB contains the given row from the row array fields[] of an MDB result

The array index corresponds to following table columns: [0] - subject, [1] - predicate, [2] - object, [3] - l_language, [4] - l_datatype, [5] - subject_is, [6] - object_is

  • Access: protected

Parameters:

array   $row   — 

[ Top ]

_convertRecordSetToMemModel   [line 887]

object Model_Memory _convertRecordSetToMemModel( ressource $result)

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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Access: protected

Parameters:

ressource   $result   —  MDB Result

[ Top ]

_createDynSqlPart_SPO   [line 950]

string _createDynSqlPart_SPO( object Resource $subject, object Resource $predicate, object Node $object)

Create the dynamic part of an sql statement selecting triples with the given parameters ($subject, $predicate, $object).
  • Access: protected

Parameters:

object Resource   $subject   — 
object Resource   $predicate   — 
object Node   $object   — 

[ Top ]

_getNodeFlag   [line 866]

string _getNodeFlag( object Node $object)

*' Return the flag of the Node object.

r - Resource, b - BlankNode, l - Literal

  • Access: protected

Parameters:

object Node   $object   — 

[ Top ]

_getRecordSet   [line 989]

resource _getRecordSet( &$model, object Model_MDB $Model_MDB)

Get an MDB result with row arrays containing a representation of

the given Model_MDB stored in the 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 (This method operates on data from a Model_MDB without loading it into a memory model in order to save resources and improve speed).

  • Return: MDB result
  • Access: protected

Parameters:

object Model_MDB   $Model_MDB   — 
   &$model   — 

[ Top ]

_insertRow   [line 1038]

void _insertRow( array $row)

Add the given row from the row array of an MDB result to this Model_MDB

The array index corresponds to following table columns: [0] - subject, [1] - predicate, [2] - object, [3] - l_language, [4] - l_datatype, [5] - subject_is, [6] - object_is

  • Throws: SqlError
  • Access: protected

Parameters:

array   $row   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:39:28 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.