CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Query
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class PostgresCompiler

Responsible for compiling a Query object into its SQL representation for Postgres

Namespace: Cake\Database

Property Summary

  • $deleteParts protected
    array<string>

    The list of query clauses to traverse for generating a DELETE statement

  • $insertParts protected
    array<string>

    The list of query clauses to traverse for generating an INSERT statement

  • $quotedSelectAliases protected
    bool

    Always quote aliases in SELECT clause.

    Postgres auto converts unquoted identifiers to lower case.

  • $selectParts protected
    array<string>

    The list of query clauses to traverse for generating a SELECT statement

  • $templates protected
    array<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 protected
    array<string>

    The list of query clauses to traverse for generating an UPDATE statement

Method Summary

  • buildExceptPart() protected

    Builds the SQL string for all the EXCEPT clauses in this query, when dealing with query objects it will also transform them using their configured SQL dialect.

  • buildFromPart() protected

    Helper 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() protected

    Helper 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() protected

    Builds the SQL fragment for INSERT INTO.

  • buildIntersectPart() protected

    Builds 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() protected

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

  • buildModifierPart() protected

    Builds the SQL modifier fragment

  • buildOptimizerHintPart() protected

    Builds the optimizer hint comment part.

  • buildSelectPart() protected

    Helper 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() protected

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

  • buildSetPart() protected

    Helper function to generate SQL for SET expressions.

  • buildUnionPart() protected

    Builds 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() protected

    Builds the SQL fragment for UPDATE.

  • buildValuesPart() protected

    Builds the SQL fragment for INSERT INTO.

  • buildWindowPart() protected

    Helper function to build the string representation of a window clause.

  • buildWithPart() protected

    Helper function used to build the string representation of a WITH clause, it constructs the CTE definitions list and generates the RECURSIVE keyword when required.

  • compile() public

    Returns the SQL representation of the provided query after generating the placeholders for the bound values using the provided generator

  • sqlCompiler() protected

    Returns a closure that can be used to compile a SQL string representation of this query.

  • stringifyExpressions() protected

    Helper function used to convert ExpressionInterface objects inside an array into their string representation.

Method Detail

buildExceptPart() ¶ protected

buildExceptPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Builds the SQL string for all the EXCEPT 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 EXCEPT

Cake\Database\Query $query

The query that is being compiled

Cake\Database\ValueBinder $binder

Value binder used to generate parameter placeholder

Returns
string

buildFromPart() ¶ protected

buildFromPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Helper 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): string

Helper 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): string

Builds the SQL fragment for INSERT INTO.

Parameters
array $parts

The insert parts.

Cake\Database\Query $query

The query that is being compiled

Cake\Database\ValueBinder $binder

Value binder used to generate parameter placeholder

Returns
string

SQL fragment.

buildIntersectPart() ¶ protected

buildIntersectPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Builds 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): string

Helper 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

buildModifierPart() ¶ protected

buildModifierPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Builds 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
string

SQL fragment.

buildOptimizerHintPart() ¶ protected

buildOptimizerHintPart(list<string> $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Builds the optimizer hint comment part.

Parameters
list<string> $parts

The optimizer hints

Cake\Database\Query $query

The query that is being compiled

Cake\Database\ValueBinder $binder

Value binder used to generate parameter placeholder

Returns
string

Optimizer hint comment

buildSelectPart() ¶ protected

buildSelectPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Helper 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): string

Builds 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): string

Helper 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): string

Builds 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): string

Builds 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
string

SQL fragment.

buildValuesPart() ¶ protected

buildValuesPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Builds 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
string

SQL fragment.

buildWindowPart() ¶ protected

buildWindowPart(array $parts, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Helper 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): string

Helper function used to build the string representation of a WITH clause, it constructs the CTE definitions list and generates the RECURSIVE keyword when required.

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

compile() ¶ public

compile(Cake\Database\Query $query, Cake\Database\ValueBinder $binder): string

Returns 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
string

sqlCompiler() ¶ protected

sqlCompiler(string $sql, Cake\Database\Query $query, Cake\Database\ValueBinder $binder): Closure

Returns 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): array

Helper function used to convert 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
array

Property 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

Always quote aliases in SELECT clause.

Postgres auto converts unquoted identifiers to lower case.

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>
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs