[ Expand All ] [ Collapse All ] - [ Properties (3) ] [ Methods (44) ] - [ Legend ]

DbModel Class v. V0.9.1

Object
Model
DbModel

Class: DbModel ----------------------------------------------------------------------------------

This class provides methods for manipulating DbModels from DbStore. A DbModel is an RDF Model, which is persistently stored in a relational database. This Class uses ADOdb Library for PHP V3.60 ( http://php.weblogs.com/ADODB ).

<BR><BR>History:<UL> <LI>12-06-2004 : improved namespace handling added ( tobias.gauss@web.de )</LI> <LI>10-07-2004 : Function findFirstMatchingStatement() added paramter $offset to set an search offset <LI>16-08-2004 : Function getUniqueResourceURI() has been made faster,</LI> addWithoutDuplicates() added</LI> <LI>05-24-2004 : Bug in _getNodeFlag() fixed ( auer@informatik.uni-leipzig.de )</LI> <LI>03-29-2004 : Function addModel() fixed, saveAs() added</LI> <LI>11-13-2003 : Functions load,saveAs moved to class model <LI>11-12-2003 : Function rdqlQueryAsIterator() added.</LI> <LI>06-17-2003 : First version of this class</LI>

AuthorRadoslaw Oldakowski
Properties implemented by DbModel
private method dbConn

Database connection object

private method modelID

Database internal modelID. Used to avoid JOINs.

private method modelURI

Unique model URI. Used to identify the DbModel.

Methods implemented by DbModel
private method _checkBaseURI

PHPstring _checkBaseURI(string $uri)

============================================================================= **************************** private methods ******************************** =============================================================================

If the URI doesn't end with # : or /, then a # is added to the URI. Used at setting the baseURI of this DbModel.

Arguments

private method _checkNamespace

PHP_checkNamespace(unknown $nmsp)

checks if a namespace is already in the model.

AuthorTobias Gauß

Arguments

private method _containsRow

PHPboolean _containsRow(array $row)

Check if this DbModel contains the given row from the array fields[] of an ADORecordSet 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

Arguments

private method _convertRecordSetToMemModel

PHPobject _convertRecordSetToMemModel(unknown $recordSet)

Convert an ADORecordSet to a memory Model.

Every successful database query returns an ADORecordSet object which is actually a cursor that holds the current row in the array fields[]. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! This method can only be applied to a RecordSet with array fields[] !!! 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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Arguments

Return

MemModel

private method _createDynSqlPart_SPO

PHPstring _createDynSqlPart_SPO(unknown $subject, unknown $predicate, unknown $object)

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

Arguments

private method _getNodeFlag

PHPstring _getNodeFlag(unknown $object)

*' Return the flag of the Node object. r - Resource, b - BlankNode, l - Literal

Arguments

private method _getRecordSet

PHPobject _getRecordSet(unknown $dbModel)

Get an ADORecordSet with array fields[] containing a representation of the given DbModel 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 DbModel without loading it into a memory model in order to save resources and improve speed).

Arguments

Return

ADORecordSet

public method add

PHPadd(unknown $statement)

Add a new triple to this DbModel.

Arguments

public method addModel

PHPaddModel(unknown $model)

Add the given model to this DbModel. 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.

Arguments

public method addNamespace

PHPaddNamespace(string $prefix, unknown $nmsp)

Adds a namespace and prefix to the model.

AuthorTobias Gauß

Arguments

public method addParsedNamespaces

PHPaddParsedNamespaces(array $newNs)

Adds the namespaces to the model. This method is called by the parser. !!!! addParsedNamespaces() not overwrites manual added namespaces in the model !!!!

AuthorTobias Gauß

Arguments

public method addWithoutDuplicates

PHPaddWithoutDuplicates(unknown $statement)

Alias for the method add()

Arguments

public method close

PHPclose()

Close this DbModel

public method contains

PHPboolean contains(unknown $statement)

Check if the DbModel contains the given statement

Arguments

public method containsAll

PHPboolean containsAll(unknown $model)

Determine if all of the statements in the given model are also contained in this DbModel.

Arguments

public method containsAny

PHPboolean containsAny(unknown $model)

Determine if any of the statements in the given model are also contained in this DbModel.

Arguments

constructor DbModel

PHPDbModel(unknown $dbConnection, string $modelURI, string $modelID, string $baseURI)

Constructor Do not call this directly. Use the method getModel,getNewModel or putModel of the Class DbStore instead.

Arguments

public method delete

PHPdelete()

Remove this DbModel from database and clean up. This function monitors for SQL errors, and will commit if no errors have occured, otherwise it will rollback.

public method equals

PHPboolean equals(unknown $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.

Arguments

public method find

PHPobject find(unknown $subject, unknown $predicate, unknown $object)

General method to search for triples in the DbModel. NULL input for any parameter will match anything. Example: $result = $m->find( NULL, NULL, $node ); Finds all triples with $node as object.

Arguments

Return

MemModel

public method findCount

PHPinteger findCount(unknown $subject, unknown $predicate, unknown $object)

Search for triples and return the number of matches. NULL input for any parameter will match anything.

Arguments

public method findFirstMatchingStatement

PHPobject findFirstMatchingStatement(unknown $subject, unknown $predicate, unknown $object, integer $offset)

Search for triples and return the first matching statement. NULL input for any parameter will match anything. Return an NULL if nothing is found. You can set an search offset with $offset.

Arguments

Return

Statement

public method findRegex

PHPobject 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 MemModel if nothing is found. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING: Mhis method loads a DbModel into memory and performs the search on a MemModel, which can be slow with large models. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Arguments

Return

MemModel

public method findVocabulary

PHPobject 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.

Arguments

Return

MemModel

public method getMemModel

PHPobject getMemModel()

Create a MemModel containing all the triples of the current DbModel

Return

MemModel

public method getParsedNamespaces

PHParray getParsedNamespaces()

Returns the models namespaces.

AuthorTobias Gauß
public method intersect

PHPobject intersect(unknown $model)

Return a new MemModel containing all the statements which are in both this model and the given model.

Arguments

Return

MemModel

public method isEmpty

PHPboolean isEmpty()

Check if this DbModel is empty

public method rdqlQuery

PHParray rdqlQuery(string $queryString, boolean $returnNodes)

Perform an RDQL query on this DbModel. This method returns an associative array of variable bindings. The values of the query variables can either be RAP's objects (instances of Node) if $returnNodes set to TRUE, or their string serialization.

Arguments

Return

[][?VARNAME] = object Node (if $returnNodes = TRUE) OR array [][?VARNAME] = string

public method rdqlQueryAsIterator

PHPobject rdqlQueryAsIterator(string $queryString, boolean $returnNodes)

Perform an RDQL query on this DBModel. This method returns an RdqlResultIterator of variable bindings. The values of the query variables can either be RAP's objects (instances of Node) if $returnNodes set to TRUE, or their string serialization.

Arguments

Return

RdqlResultIterator = with values as object Node (if $returnNodes = TRUE) OR object RdqlResultIterator = with values as strings if (if $returnNodes = FALSE)

public method reify

PHPobject reify()

Reify the DbModel. Return a new MemModel that contains the reifications of all statements of this DbModel.

Return

MemModel

public method remove

PHPremove(unknown $statement)

Remove the given triple from this DbModel.

Arguments

public method removeNamespace

PHPremoveNamespace(string $nmsp)

removes a single namespace from the model

AuthorTobias Gauß

Arguments

public method replace

PHPreplace(unknown $subject, unknown $predicate, unknown $object, unknown $replacement)

General method to replace nodes of a DbModel. 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.

Arguments

public method saveAs

PHPboolean saveAs(string $filename, string $type)

Saves the RDF,N3 or N-Triple serialization of the DbModel 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 DbModel couldn't be saved to the file.

Arguments

public method setBaseURI

PHPsetBaseURI(string $uri)

Set a base URI for the DbModel. Affects creating of new resources and serialization syntax.

Arguments

public method size

PHPinteger size()

Return the number of statements in this DbModel

public method subtract

PHPobject subtract(unknown $model)

Return a new MemModel that is the subtraction of another model from this DbModel.

Arguments

Return

MemModel

public method toString

PHPstring toString()

Short dump of the DbModel.

public method toStringIncludingTriples

PHPstring toStringIncludingTriples()

Dump of the DbModel including all triples.

public method unite

PHPobject unite(unknown $model)

Return a new MemModel 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 !!!!!!!!!!!)

Arguments

Return

MemModel

public method writeAsHtml

PHPwriteAsHtml()

Write the RDF serialization of the _DbModel as HTML.

public method writeAsHtmlTable

PHPwriteAsHtmlTable()

Write the RDF serialization of the DbModel as HTML table.

public method writeRdfToString

PHPstring writeRdfToString()

Write the RDF serialization of the DbModel to string

Generated by PHPEdit - Copyright © 1999-2004 - Sébastien Hordeaux - WaterProof SARL