Class SparqlEngineDb_TypeSorter

Description

Sorts database types as the Sparql specs want it.

Located in /sparql/SparqlEngineDb/TypeSorter.php (line 9)


	
			
Variable Summary
static array $arCastTypes
static array $arTypeNumbers
Method Summary
static int compareXsdType (string $strType1, string $strType2)
static string getCastMethod (string $strType, string $strSqlVar)
static int getXsdTypeNumber (string $strType)
SparqlEngineDb_TypeSorter __construct (Query $query,  $dbConn)
int compareTypeSet (array $arTs1, array $arTs2)
array getOrderifiedSqls ( $arSqls, string $strSelect, string $strFrom, string $strWhere)
string getSqlOrderBy ([arrray $arTypeSet = array()])
void getStringNullComparison ( $str)
array getTypeSets (array $arSpecialVars, string $strFrom, string $strWhere)
string getTypesetWhereClause (array $arTypeSet)
boolean isSpecialOrderVariable (string $strVar)
array orderTypeSets (array $arTypes)
boolean willBeDataDependent ()
Variables
static array $arCastTypes = array(
'http://www.w3.org/2001/XMLSchema#integer' => 'SIGNED INTEGER'
)
(line 28)

SQL types to cast XSD schema types to, so that they will get sorted correctly.

  • access: public
static array $arTypeNumbers = array(
null => 0,//empty
'b' => 1,//blank
'r' => 2,//resource
'l' => 3,//literal
)
(line 16)

Defines the sort order for value types in the database, so that they get sorted correctly as the specs want it.

  • access: public
Methods
static compareXsdType (line 310)

Compares two XSD data types and returns the comparison number.

  • return: Comparison number (<0 if $strType1 is less than $strType2, 0 if equal, >0 if type2 is greater)
  • access: public
static int compareXsdType (string $strType1, string $strType2)
  • string $strType1: First data type
  • string $strType2: Second data type
static getCastMethod (line 383)

Returns the SQL statement needed to case the given variable to the given type.

  • return: SQL command to cast the variable
  • access: protected
static string getCastMethod (string $strType, string $strSqlVar)
  • string $strType: XML data type
  • string $strSqlVar: SQL variable name
static getXsdTypeNumber (line 323)

Returns the type number for an xsd data type.

  • return: Some integer to compare two types.
  • access: public
static int getXsdTypeNumber (string $strType)
  • string $strType: XSD data type
Constructor __construct (line 34)
  • access: public
SparqlEngineDb_TypeSorter __construct (Query $query,  $dbConn)
  • Query $query
  • ADOConnection $dbConn
compareTypeSet (line 273)

Compares two type sets. Works like a normal comparision method that returns -1/0/1 for use in usort()

  • return: Comparison value
  • access: public
int compareTypeSet (array $arTs1, array $arTs2)
  • array $arTs1: First typeset
  • array $arTs2: Second typeset
getOrderifiedSqls (line 81)

Returns an array of sql statements that need to be executed and deliver the full result set when combined.

Execute setData() before this.

  • return: Array of arrays. Imploding an array will give a complete sql statement. The array will have the keys select/from/where/order.
  • access: public
array getOrderifiedSqls ( $arSqls, string $strSelect, string $strFrom, string $strWhere)
  • string $strSelect: SELECT clause
  • string $strFrom: FROM clause
  • string $strWhere: WHERE clause
  • $arSqls
getSpecialOrderVariables (line 156)

Returns an array of variables that the result is going to be ordered by and that need to be sorted multiple times (because they may contain different data types)

  • return: Array of sparql variable names
  • access: protected
array getSpecialOrderVariables ()
getSqlOrderBy (line 347)

Returns the ORDER BY sql query string if neccessary for the query. The returned string already has ORDER BY prefixed.

  • return: ORDER BY ... string or empty string
string getSqlOrderBy ([arrray $arTypeSet = array()])
  • arrray $arTypeSet: Single typeset
getStringNullComparison (line 430)

Returns the correct sql string comparison method.

  • access: protected
void getStringNullComparison ( $str)
  • $str
getTypeSets (line 205)

Determines the type sets in the query results.

A type set is a distinct set of variables and their types, e.g. the variable and its type (r/b/l) and its datatype if its an object.

  • return: Key is the sparql variable name, value is an array. This one has one key 'type' with a value of b/l/r. It might have another key 'datatype' with the resource's datatype.
  • access: protected
array getTypeSets (array $arSpecialVars, string $strFrom, string $strWhere)
  • array $arSpecialVars: Special variables as returned by getSpecialOrderVariables()
  • string $strFrom: FROM part of the sql query
  • string $strWhere: WHERE part of the sql query
getTypesetWhereClause (line 403)

Creates and returns the SQL WHERE clauses needed to get only data in the given typeset.

  • return: Clauses for the WHERE part in an SQL query
  • access: protected
string getTypesetWhereClause (array $arTypeSet)
  • array $arTypeSet: Typeset
isSpecialOrderVariable (line 181)

Checks if a given variable name is a variable that needs special care when used in ORDER BY statements.

  • return: true if the variable needs special care
  • access: protected
boolean isSpecialOrderVariable (string $strVar)
  • string $strVar: SPARQL variable name
orderTypeSets (line 247)

Takes an array of type sets (as returned by getTypeSets()) and sorts the variables according to the SPARQL specs.

  • return: Ordered array of type sets
  • access: protected
array orderTypeSets (array $arTypes)
  • array $arTypes: Array of type sets
setData (line 46)

Needs to be executed before getOrderifiedSqls and willBeDataDependent

  • access: public
void setData (SparqlEngineDb_SqlGenerator $sg)
willBeDataDependent (line 138)

Returns wether the returned queries will depend on the data or not.

If the queries depend on the data, they cannot be prepare()d and thus won't be that fast when executing.

Execute setData() before this.

  • access: public
boolean willBeDataDependent ()

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