Class SparqlEngineDb_SqlGenerator

Description

Creates sql statements from a Query object

Located in /sparql/SparqlEngineDb/SqlGenerator.php (line 13)


	
			
Variable Summary
Method Summary
static string getSqlEqualityCondition (array $arNew, array $arOld)
static boolean isEmptyPattern (GraphPattern $graphPattern)
static boolean isPreparedVariable ( $bject)
static boolean isResultVar (string $strVar,  &$arResultVars, array $arResultVars)
static boolean isVariable ( $bject)
static array removeNull (array $array)
SparqlEngineDb_SqlGenerator __construct (Query $query,  $dbConn,  $modelID)
array createEqualSelects (array $arSelect)
array createSql ()
void fixWhere ( $strWhere)
void getPlaceholders ()
string getPreparedVariablePlaceholder (string $strVariable)
string getSqlCondition (mixed $bject, string $strTablePrefix, string $strType)
void getSqlVariableName ( $strSparqlVar)
void getSqlVariableNameDatatype ( $strSparqlVar)
void getSqlVariableNameIs ( $strSparqlVar)
void getSqlVariableNameLanguage ( $strSparqlVar)
void getSqlVariableNameValue ( $strSparqlVar)
array getTripleSql (QueryTriple $triple, GraphPattern $graphPattern,  $arResultVars)
void getUsedVarTypes ()
Variables
static array $arTableColumnNames = array(
's' => array(
'value' => 'subject',
'is' => 'subject_is'
),'p'=>array('value'=>'predicate'),'o'=>array('value'=>'object','is'=>'object_is'))
(line 108)

Column names for subjects, predicates and objects for easy access via their character names (spo).

  • access: public
array $arPlaceholders = array() (line 99)

Array with placeholders of prepared statements variables.

key is the variable name (without "??"), value is the placeholder.

  • access: protected
array $arUnionVarAssignments = array() (line 72)

Array of arrays that contain all variable names which are to be found in the result of an sql statement in a union.

  • access: public
  • example: example not found
array $arUsedVarAssignments = array() (line 51)

Array of variable name => table.col assignments for all variables used in the query not only the ones that shall be returned.

  • access: public
  • example: example not found
array $arUsedVarTypes = array() (line 91)

Which variables have been used as which type? key is variable name, value is an array of max. three keys (s, p, o)

  • access: protected
  • example: example not found
array $arVarAssignments = array() (line 37)

Determines which variables can be found in which SQL result column.

  • see: $arCreationMethods
  • access: public
  • example: example not found
mixed $nSqlVariableNameCount = 0 (line 128)
  • access: protected
int $nUnionCount = 0 (line 126)

Current UNION part number

  • access: protected
mixed $query = null (line 15)
  • access: public
Methods
static getSqlEqualityCondition (line 652)

Checks if the sentence part (subject, predicate or object) in $arNew has the same content as $arOld.

Required for queries like ":x ?a ?a" where predicate and object need to have the same value

  • access: protected
static string getSqlEqualityCondition (array $arNew, array $arOld)
  • array $arNew: array($strTablePrefix, $strType = s|p|o)
  • array $arOld: array($strTablePrefix, $strType = s|p|o)
static isEmptyPattern (line 798)

Checks if the graph pattern is empty (contains no usable data).

Occurs when using "{}" without pre- or suffixes WHERE { { ?person rdf:type foaf:Person } . }

  • return: True if the pattern is empty.
  • access: protected
static boolean isEmptyPattern (GraphPattern $graphPattern)
static isPreparedVariable (line 728)

Checks if the given variable is a replacement for a prepared statement.

  • access: public
static boolean isPreparedVariable ( $bject)
  • $bject
static isResultVar (line 701)

Checks if the given variable name is part of the result variables list.

Needed since $arResultVars may contain "*" that captures all variables.

  • return: true if it is a result variable
  • access: protected
static boolean isResultVar (string $strVar,  &$arResultVars, array $arResultVars)
  • string $strVar: Variable name (e.g. "?p")
  • array $arResultVars: Array with result variables
  • &$arResultVars
static isVariable (line 714)

Checks if the given subject/predicate/object is a variable name.

  • access: public
static boolean isVariable ( $bject)
  • $bject
static removeNull (line 817)

Removes all NULL values from an array and returns it.

  • return: without the NULL values.
  • access: protected
static array removeNull (array $array)
  • array $array: Some array
Constructor __construct (line 132)
  • access: public
SparqlEngineDb_SqlGenerator __construct (Query $query,  $dbConn,  $modelID)
  • Query $query
  • ADOConnection $dbConn
  • $modelID
createEqualSelects (line 466)

Creates SELECT statements that have the same number of columns.

Needed for UNIONs.

  • return: Array of SELECT strings
  • access: protected
array createEqualSelects (array $arSelect)
  • array $arSelect: Array of arrays. array( //for each union part one
    1. => array( //foreach triple pattern 0 => array( '?person' => array( 't0.subject as "t0.subject"' ) )
    ) )
createSql (line 150)

Creates an SQL query string from the given Sparql query object.

  • return: Array of arrays of SQL query string parts: select, from and where
  • throws: SparqlEngineDb_SqlGeneratorException If there is no variable in the result set.
array createSql ()
fixWhere (line 833)

Removes a leading AND from the where clause which would render the sql illegal.

  • access: protected
void fixWhere ( $strWhere)
  • $strWhere
getPlaceholders (line 758)
  • access: public
void getPlaceholders ()
getPreparedVariablePlaceholder (line 746)

Returns a placeholder to be included in the sql statement.

It will be replaced with a real prepared statement variable later on. Also adds it to the internal placeholder array.

  • return: placeholder
  • access: protected
string getPreparedVariablePlaceholder (string $strVariable)
  • string $strVariable: The variable to get a placeholder for
getSqlCondition (line 558)

Creates an SQL statement that checks for the value of some subject/predicate/object

  • return: Part of the SQL query (prefixed with AND)
string getSqlCondition (mixed $bject, string $strTablePrefix, string $strType)
  • mixed $bject: subject|predicate|object
  • string $strTablePrefix: Table prefix (e.g. "t0")
  • string $strType: Type of $bject ('subject'|'predicate'|'object')
getSqlVariableName (line 844)
  • access: protected
void getSqlVariableName ( $strSparqlVar)
  • $strSparqlVar
getSqlVariableNameDatatype (line 886)
  • access: protected
void getSqlVariableNameDatatype ( $strSparqlVar)
  • $strSparqlVar
getSqlVariableNameIs (line 868)
  • access: protected
void getSqlVariableNameIs ( $strSparqlVar)
  • $strSparqlVar
getSqlVariableNameLanguage (line 877)
  • access: protected
void getSqlVariableNameLanguage ( $strSparqlVar)
  • $strSparqlVar
getSqlVariableNameValue (line 859)
  • access: protected
void getSqlVariableNameValue ( $strSparqlVar)
  • $strSparqlVar
getTripleSql (line 286)

Creates some SQL statements from the given triple pattern array.

  • return: Array consisting of on array and two string values: SELECT, FROM and WHERE part
array getTripleSql (QueryTriple $triple, GraphPattern $graphPattern,  $arResultVars)
  • QueryTriple $triple: Array containing subject, predicate and object
  • GraphPattern $graphPattern: Graph pattern object
  • $arResultVars
getUsedVarAssignments (line 772)
  • access: public
void getUsedVarAssignments ()
getUsedVarTypes (line 779)
  • access: public
void getUsedVarTypes ()
getVarAssignments (line 765)
  • access: public
void getVarAssignments ()

Documentation generated on Fri, 1 Jun 2007 16:52:24 +0200 by phpDocumentor 1.3.2