phpcr-utils/src/PHPCR/Util/QOM/QomToSql2QueryConverter.php
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\PHPCR\Util\QOM\QomToSql2QueryConverter
Properties
\PHPCR\Util\QOM\BaseSqlGenerator $generator
Methods
__construct(\PHPCR\Util\QOM\BaseSqlGenerator $generator) : void
Instantiate the converter
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::__construct()Name | Type | Description |
---|---|---|
$generator | \PHPCR\Util\QOM\BaseSqlGenerator |
convert(\PHPCR\Query\QOM\QueryObjectModelInterface $query) : string
Query ::= 'SELECT' columns 'FROM' Source ['WHERE' Constraint] ['ORDER BY' orderings]
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convert()Name | Type | Description |
---|---|---|
$query | \PHPCR\Query\QOM\QueryObjectModelInterface |
Type | Description |
---|---|
string |
convertBindVariable(string $var) : string
BindVariableValue ::= '$'bindVariableName bindVariableName ::= Prefix
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertBindVariable()Name | Type | Description |
---|---|---|
$var | string |
Type | Description |
---|---|
string |
convertChildNodeJoinCondition(\PHPCR\Query\QOM\ChildNodeJoinConditionInterface $condition) : string
ChildNodeJoinCondition ::= 'ISCHILDNODE(' childSelectorName ',' parentSelectorName ')' childSelectorName ::= selectorName parentSelectorName ::= selectorName
Name | Type | Description |
---|---|---|
$condition | \PHPCR\Query\QOM\ChildNodeJoinConditionInterface |
Type | Description |
---|---|
string |
convertColumns(\PHPCR\Query\QOM\ColumnInterface[] $columns) : string
columns ::= (Column ',' {Column}) | '*' Column ::= ([selectorName'.']propertyName ['AS' columnName]) | (selectorName'.*') // If only one selector exists selectorName ::= Name propertyName ::= Name columnName ::= Name
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertColumns()Name | Type | Description |
---|---|---|
$columns | \PHPCR\Query\QOM\ColumnInterface[] |
Type | Description |
---|---|
string |
convertComparison(\PHPCR\Query\QOM\ComparisonInterface $comparison) : string
Comparison ::= DynamicOperand Operator StaticOperand
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertComparison()Operator ::= EqualTo | NotEqualTo | LessThan | LessThanOrEqualTo | GreaterThan | GreaterThanOrEqualTo | Like EqualTo ::= '=' NotEqualTo ::= '<>' LessThan ::= '<' LessThanOrEqualTo ::= '<=' GreaterThan ::= '>' GreaterThanOrEqualTo ::= '>=' Like ::= 'LIKE'
Name | Type | Description |
---|---|---|
$comparison | \PHPCR\Query\QOM\ComparisonInterface |
Type | Description |
---|---|
string |
convertConstraint(\PHPCR\Query\QOM\ConstraintInterface $constraint) : string
Constraint ::= And | Or | Not | Comparison | PropertyExistence | FullTextSearch | SameNode | ChildNode | DescendantNode
And ::= constraint1 'AND' constraint2 Or ::= constraint1 'OR' constraint2 Not ::= 'NOT' Constraint
SameNode ::= 'ISSAMENODE(' [selectorName ','] Path ')' // If only one selector exists in this query, explicit specification of the selectorName is optional
ChildNode ::= 'ISCHILDNODE(' [selectorName ','] Path ')' // If only one selector exists in this query, explicit specification of the selectorName is optional
DescendantNode ::= 'ISDESCENDANTNODE(' [selectorName ','] Path ')' // If only one selector exists in this query, explicit specification of the selectorName is optional
Name | Type | Description |
---|---|---|
$constraint | \PHPCR\Query\QOM\ConstraintInterface |
Type | Description |
---|---|
string |
convertDescendantNodeJoinCondition(\PHPCR\Query\QOM\DescendantNodeJoinConditionInterface $condition) : string
DescendantNodeJoinCondition ::= 'ISDESCENDANTNODE(' descendantSelectorName ',' ancestorSelectorName ')' descendantSelectorName ::= selectorName ancestorSelectorName ::= selectorName
Name | Type | Description |
---|---|---|
$condition | \PHPCR\Query\QOM\DescendantNodeJoinConditionInterface |
Type | Description |
---|---|
string |
convertDynamicOperand(\PHPCR\Query\QOM\DynamicOperandInterface $operand) : string
DynamicOperand ::= PropertyValue | Length | NodeName | NodeLocalName | FullTextSearchScore | LowerCase | UpperCase
Length ::= 'LENGTH(' PropertyValue ')' NodeName ::= 'NAME(' [selectorName] ')' // If only one selector exists NodeLocalName ::= 'LOCALNAME(' [selectorName] ')' // If only one selector exists FullTextSearchScore ::= 'SCORE(' [selectorName] ')' // If only one selector exists LowerCase ::= 'LOWER(' DynamicOperand ')' UpperCase ::= 'UPPER(' DynamicOperand ')'
Name | Type | Description |
---|---|---|
$operand | \PHPCR\Query\QOM\DynamicOperandInterface |
Type | Description |
---|---|
string |
convertEquiJoinCondition(\PHPCR\Query\QOM\EquiJoinConditionInterface $condition) : string
EquiJoinCondition ::= selector1Name'.'property1Name '=' selector2Name'.'property2Name selector1Name ::= selectorName selector2Name ::= selectorName property1Name ::= propertyName property2Name ::= propertyName
Name | Type | Description |
---|---|---|
$condition | \PHPCR\Query\QOM\EquiJoinConditionInterface |
Type | Description |
---|---|
string |
convertFullTextSearch(\PHPCR\Query\QOM\FullTextSearchInterface $constraint) : string
FullTextSearch ::= 'CONTAINS(' ([selectorName'.']propertyName | selectorName'.*') ',' FullTextSearchExpression ')' // If only one selector exists in this query, explicit specification of the selectorName preceding the propertyName is optional
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertFullTextSearch()Name | Type | Description |
---|---|---|
$constraint | \PHPCR\Query\QOM\FullTextSearchInterface |
Type | Description |
---|---|
string |
convertFullTextSearchExpression(string $expr) : string
FullTextSearchExpression ::= BindVariable | ''' FullTextSearchLiteral '''
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertFullTextSearchExpression()Name | Type | Description |
---|---|---|
$expr | string |
Type | Description |
---|---|
string |
convertJoin(\PHPCR\Query\QOM\JoinInterface $join) : string
Join ::= left [JoinType] 'JOIN' right 'ON' JoinCondition // If JoinType is omitted INNER is assumed.
left ::= Source right ::= Source
JoinType ::= Inner | LeftOuter | RightOuter Inner ::= 'INNER' LeftOuter ::= 'LEFT OUTER' RightOuter ::= 'RIGHT OUTER'
Name | Type | Description |
---|---|---|
$join | \PHPCR\Query\QOM\JoinInterface |
Type | Description |
---|---|
string |
convertJoinCondition(\PHPCR\Query\QOM\JoinConditionInterface $condition) : string
JoinCondition ::= EquiJoinCondition | SameNodeJoinCondition | ChildNodeJoinCondition | DescendantNodeJoinCondition
Name | Type | Description |
---|---|---|
$condition | \PHPCR\Query\QOM\JoinConditionInterface |
Type | Description |
---|---|
string |
convertLiteral(mixed $literal) : string
Literal ::= CastLiteral | UncastLiteral
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertLiteral()Name | Type | Description |
---|---|---|
$literal | mixed |
Type | Description |
---|---|
string |
convertOrderings(\PHPCR\Query\QOM\OrderingInterface[] $orderings) : string
orderings ::= Ordering {',' Ordering} Ordering ::= DynamicOperand [Order] Order ::= Ascending | Descending Ascending ::= 'ASC' Descending ::= 'DESC'
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertOrderings()Name | Type | Description |
---|---|---|
$orderings | \PHPCR\Query\QOM\OrderingInterface[] |
Type | Description |
---|---|
string |
convertPath(string $path) : string
Path ::= '[' quotedPath ']' | '[' simplePath ']' | simplePath quotedPath ::= A JCR Path that contains non-SQL-legal characters simplePath ::= A JCR Name that contains only SQL-legal characters
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertPath()Name | Type | Description |
---|---|---|
$path | string |
Type | Description |
---|---|
string |
convertPropertyExistence(\PHPCR\Query\QOM\PropertyExistenceInterface $constraint) : string
PropertyExistence ::= selectorName'.'propertyName 'IS NOT NULL' | propertyName 'IS NOT NULL' If only one selector exists in this query
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertPropertyExistence()Note: The negation, 'NOT x IS NOT NULL' can be written 'x IS NULL'
Name | Type | Description |
---|---|---|
$constraint | \PHPCR\Query\QOM\PropertyExistenceInterface |
Type | Description |
---|---|
string |
convertPropertyValue(\PHPCR\Query\QOM\PropertyValueInterface $value) : string
PropertyValue ::= [selectorName'.'] propertyName // If only one selector exists
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertPropertyValue()Name | Type | Description |
---|---|---|
$value | \PHPCR\Query\QOM\PropertyValueInterface |
Type | Description |
---|---|
string |
convertSameNodeJoinCondition(\PHPCR\Query\QOM\SameNodeJoinConditionInterface $condition) : string
SameNodeJoinCondition ::= 'ISSAMENODE(' selector1Name ',' selector2Name [',' selector2Path] ')' selector2Path ::= Path
Name | Type | Description |
---|---|---|
$condition | \PHPCR\Query\QOM\SameNodeJoinConditionInterface |
Type | Description |
---|---|
string |
convertSelector(\PHPCR\Query\QOM\SelectorInterface $selector) : string
Selector ::= nodeTypeName ['AS' selectorName] nodeTypeName ::= Name
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertSelector()Name | Type | Description |
---|---|---|
$selector | \PHPCR\Query\QOM\SelectorInterface |
Type | Description |
---|---|
string |
convertSource(\PHPCR\Query\QOM\SourceInterface $source) : string
Source ::= Selector | Join
This is different between SQL1 and SQL2
Name | Type | Description |
---|---|---|
$source | \PHPCR\Query\QOM\SourceInterface |
Type | Description |
---|---|
string |
convertStaticOperand(\PHPCR\Query\QOM\StaticOperandInterface $operand) : string
StaticOperand ::= Literal | BindVariableValue
Inherited from: \PHPCR\Util\QOM\BaseQomToSqlQueryConverter::convertStaticOperand()Literal ::= CastLiteral | UncastLiteral CastLiteral ::= 'CAST(' UncastLiteral ' AS ' PropertyType ')'
PropertyType ::= 'STRING' | 'BINARY' | 'DATE' | 'LONG' | 'DOUBLE' | 'DECIMAL' | 'BOOLEAN' | 'NAME' | 'PATH' | 'REFERENCE' | 'WEAKREFERENCE' | 'URI' UncastLiteral ::= UnquotedLiteral | ''' UnquotedLiteral ''' | '“' UnquotedLiteral '“' UnquotedLiteral ::= // String form of a JCR Value
BindVariableValue ::= '$'bindVariableName bindVariableName ::= Prefix
Name | Type | Description |
---|---|---|
$operand | \PHPCR\Query\QOM\StaticOperandInterface |
Type | Description |
---|---|
string |