Class SqlserverCompiler
Responsible for compiling a Query object into its SQL representation for SQL Server
Property Summary
- 
        $_deleteParts protectedarray<string>The list of query clauses to traverse for generating a DELETE statement 
- 
        $_insertParts protectedarray<string>The list of query clauses to traverse for generating an INSERT statement 
- 
        $_quotedSelectAliases protectedboolIndicate whether aliases in SELECT clause need to be always quoted. 
- 
        $_selectParts protectedarray<string>The list of query clauses to traverse for generating a SELECT statement 
- 
        $_templates protectedarray<string, string>List of sprintf templates that will be used for compiling the SQL for this query. There are some clauses that can be built as just as the direct concatenation of the internal parts, those are listed here. 
- 
        $_updateParts protectedarray<string>The list of query clauses to traverse for generating an UPDATE statement 
Method Summary
- 
          _buildFromPart() protectedHelper function used to build the string representation of a FROM clause, it constructs the tables list taking care of aliasing and converting expression objects to string. 
- 
          _buildHavingPart() protectedHelper function used to build the string representation of a HAVING clause, it constructs the field list taking care of aliasing and converting expression objects to string. 
- 
          _buildInsertPart() protectedGenerates the INSERT part of a SQL query 
- 
          _buildIntersectPart() protectedBuilds the SQL string for all the INTERSECT clauses in this query, when dealing with query objects it will also transform them using their configured SQL dialect. 
- 
          _buildJoinPart() protectedHelper function used to build the string representation of multiple JOIN clauses, it constructs the joins list taking care of aliasing and converting expression objects to string in both the table to be joined and the conditions to be used. 
- 
          _buildLimitPart() protectedGenerates the LIMIT part of a SQL query 
- 
          _buildModifierPart() protectedBuilds the SQL modifier fragment 
- 
          _buildSelectPart() protectedHelper function used to build the string representation of a SELECT clause, it constructs the field list taking care of aliasing and converting expression objects to string. This function also constructs the DISTINCT clause for the query. 
- 
          _buildSetOperationPart() protectedBuilds the SQL string for all the operationclauses in this query, when dealing with query objects it will also transform them using their configured SQL dialect.
- 
          _buildSetPart() protectedHelper function to generate SQL for SET expressions. 
- 
          _buildUnionPart() protectedBuilds the SQL string for all the UNION clauses in this query, when dealing with query objects it will also transform them using their configured SQL dialect. 
- 
          _buildUpdatePart() protectedBuilds the SQL fragment for UPDATE. 
- 
          _buildValuesPart() protectedBuilds the SQL fragment for INSERT INTO. 
- 
          _buildWindowPart() protectedHelper function to build the string representation of a window clause. 
- 
          _buildWithPart() protectedHelper function used to build the string representation of a WITHclause, it constructs the CTE definitions list without generating theRECURSIVEkeyword that is neither required nor valid.
- 
          _sqlCompiler() protectedReturns a closure that can be used to compile a SQL string representation of this query. 
- 
          _stringifyExpressions() protectedHelper function used to covert ExpressionInterface objects inside an array into their string representation. 
- 
          compile() publicReturns the SQL representation of the provided query after generating the placeholders for the bound values using the provided generator 
Method Detail
_buildFromPart() ¶ protected
_buildFromPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function used to build the string representation of a FROM clause, it constructs the tables list taking care of aliasing and converting expression objects to string.
Parameters
- 
                array$parts
- list of tables to be transformed to string 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildHavingPart() ¶ protected
_buildHavingPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function used to build the string representation of a HAVING clause, it constructs the field list taking care of aliasing and converting expression objects to string.
Parameters
- 
                array$parts
- list of fields to be transformed to string 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildInsertPart() ¶ protected
_buildInsertPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringGenerates the INSERT part of a SQL query
To better handle concurrency and low transaction isolation levels, we also include an OUTPUT clause so we can ensure we get the inserted row's data back.
Parameters
- 
                array$parts
- The parts to build 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildIntersectPart() ¶ protected
_buildIntersectPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringBuilds the SQL string for all the INTERSECT clauses in this query, when dealing with query objects it will also transform them using their configured SQL dialect.
Parameters
- 
                array$parts
- list of queries to be operated with INTERSECT 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildJoinPart() ¶ protected
_buildJoinPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function used to build the string representation of multiple JOIN clauses, it constructs the joins list taking care of aliasing and converting expression objects to string in both the table to be joined and the conditions to be used.
Parameters
- 
                array$parts
- list of joins to be transformed to string 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildLimitPart() ¶ protected
_buildLimitPart(int $limit, Cake\Database\Query $query): stringGenerates the LIMIT part of a SQL query
Parameters
- 
                int$limit
- the limit clause 
- 
                Cake\Database\Query$query
- The query that is being compiled 
Returns
string_buildModifierPart() ¶ protected
_buildModifierPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringBuilds the SQL modifier fragment
Parameters
- 
                array$parts
- The query modifier parts 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
stringSQL fragment.
_buildSelectPart() ¶ protected
_buildSelectPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function used to build the string representation of a SELECT clause, it constructs the field list taking care of aliasing and converting expression objects to string. This function also constructs the DISTINCT clause for the query.
Parameters
- 
                array$parts
- list of fields to be transformed to string 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildSetOperationPart() ¶ protected
_buildSetOperationPart(string $operation, array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringBuilds the SQL string for all the operation clauses in this query, when dealing
with query objects it will also transform them using their configured SQL
dialect.
Parameters
- 
                string$operation
- 
                array$parts
- 
                Cake\Database\Query$query
- 
                Cake\Database\ValueBinder$binder
Returns
string_buildSetPart() ¶ protected
_buildSetPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function to generate SQL for SET expressions.
Parameters
- 
                array$parts
- List of keys and values to set. 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildUnionPart() ¶ protected
_buildUnionPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringBuilds the SQL string for all the UNION clauses in this query, when dealing with query objects it will also transform them using their configured SQL dialect.
Parameters
- 
                array$parts
- list of queries to be operated with UNION 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildUpdatePart() ¶ protected
_buildUpdatePart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringBuilds the SQL fragment for UPDATE.
Parameters
- 
                array$parts
- The update parts. 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
stringSQL fragment.
_buildValuesPart() ¶ protected
_buildValuesPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringBuilds the SQL fragment for INSERT INTO.
Parameters
- 
                array$parts
- The values parts. 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
stringSQL fragment.
_buildWindowPart() ¶ protected
_buildWindowPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function to build the string representation of a window clause.
Parameters
- 
                array$parts
- List of windows to be transformed to string 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_buildWithPart() ¶ protected
_buildWithPart(array<Cake\Database\Expression\CommonTableExpression> $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringHelper function used to build the string representation of a WITH clause,
it constructs the CTE definitions list without generating the RECURSIVE
keyword that is neither required nor valid.
Parameters
- 
                array<Cake\Database\Expression\CommonTableExpression>$parts
- List of CTEs to be transformed to string 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
string_sqlCompiler() ¶ protected
_sqlCompiler(string $sql, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): ClosureReturns a closure that can be used to compile a SQL string representation of this query.
Parameters
- 
                string$sql
- initial sql string to append to 
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
Returns
Closure_stringifyExpressions() ¶ protected
_stringifyExpressions(array $expressions, Cake\Database\ValueBinder $binder, bool $wrap = true): arrayHelper function used to covert ExpressionInterface objects inside an array into their string representation.
Parameters
- 
                array$expressions
- list of strings and ExpressionInterface objects 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholder 
- 
                bool$wrap optional
- Whether to wrap each expression object with parenthesis 
Returns
arraycompile() ¶ public
compile(Cake\Database\Query $query, Cake\Database\ValueBinder $binder): stringReturns the SQL representation of the provided query after generating the placeholders for the bound values using the provided generator
Parameters
- 
                Cake\Database\Query$query
- The query that is being compiled 
- 
                Cake\Database\ValueBinder$binder
- Value binder used to generate parameter placeholders 
Returns
stringProperty Detail
$_deleteParts ¶ protected
The list of query clauses to traverse for generating a DELETE statement
Type
array<string>$_insertParts ¶ protected
The list of query clauses to traverse for generating an INSERT statement
Type
array<string>$_quotedSelectAliases ¶ protected
Indicate whether aliases in SELECT clause need to be always quoted.
Type
bool$_selectParts ¶ protected
The list of query clauses to traverse for generating a SELECT statement
Type
array<string>$_templates ¶ protected
List of sprintf templates that will be used for compiling the SQL for this query. There are some clauses that can be built as just as the direct concatenation of the internal parts, those are listed here.
Type
array<string, string>$_updateParts ¶ protected
The list of query clauses to traverse for generating an UPDATE statement
Type
array<string>