CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 面包店
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻
    • LinkedIn
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 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

命名空间

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

类 Postgres

类 Postgres

命名空间: Cake\Database\Driver

常量

  • int|null
    MAX_ALIAS_LENGTH ¶
    63
  • array<int>
    RETRY_ERROR_CODES ¶
    []
  • class-stringCake\Database\Statement\Statement>
    STATEMENT_CLASS ¶
    Statement::class

属性概览

  • $_autoQuoting protected
    bool

    指示驱动程序是否对所有查询进行自动标识符引用

  • $_baseConfig protected
    array<string, mixed>

    Postgres 驱动程序的基本配置设置

  • $_config protected
    array<string, mixed>

    配置数据。

  • $_endQuote protected
    string

    用于结束数据库标识符引用的字符串,以使其安全

  • $_schemaDialect protected
    Cake\Database\Schema\SchemaDialect

    此驱动程序的模式方言

  • $_startQuote protected
    string

    用于开始数据库标识符引用的字符串,以使其安全

  • $_version protected
    string|null

    服务器版本

  • $connectRetries protected
    int

    最后一次连接重试尝试次数。

  • $logger protected
    ?LoggerInterface

    日志记录器实例。

  • $pdo protected
    PDO|null

    PDO 实例。

  • $quoter protected
    Cake\Database\IdentifierQuoter|null

    标识符引用器

方法概览

  • __construct() public

    构造函数

  • __debugInfo() public

    返回一个数组,可用于描述此对象的内部状态。

  • __destruct() public

    析构函数

  • _deleteQueryTranslator() protected

    将翻译步骤应用于删除查询。

  • _expressionTranslators() protected

    返回一个关联数组,其中包含将 Expression 对象转换为符合特定 SQL 方言的方法。键是类名,值是此类中的方法。

  • _insertQueryTranslator() protected

    将翻译步骤应用于插入查询。

  • _removeAliasesFromConditions() protected

    从查询的 WHERE 子句中删除别名。

  • _selectQueryTranslator() protected

    将翻译步骤应用于选择查询。

  • _transformDistinct() protected

    在重写 DISTINCT 子句后返回传递的查询,以便不支持“ON”部分的驱动程序可以提供实际执行方式

  • _transformFunctionExpression() protected

    接收 FunctionExpression 并对其进行更改,使其符合此 SQL 方言。

  • _transformIdentifierExpression() protected

    将标识符表达式更改为 postgresql 格式。

  • _transformStringExpression() protected

    将字符串表达式更改为 postgresql 格式。

  • _updateQueryTranslator() protected

    将翻译步骤应用于更新查询。

  • beginTransaction() public

    开始事务。

  • commitTransaction() public

    提交事务。

  • compileQuery() public

    将传递的查询转换为此驱动程序的方言,并返回已转换查询的实例以及完全编译的 SQL 字符串。

  • config() public

    获取用于创建驱动程序的配置数据。

  • connect() public

    建立与数据库服务器的连接。

  • createLogger() protected

    创建日志记录器实例。

  • createPdo() protected

    建立与数据库服务器的连接

  • createQueryException() protected

    从 PDOException 创建 QueryException

  • disableAutoQuoting() public

    禁用查询中标识符的自动引用。

  • disableForeignKeySQL() public

    获取用于禁用外键的 SQL。

  • disconnect() public

    断开与数据库服务器的连接。

  • enableAutoQuoting() public

    设置此驱动程序是否应在查询中自动引用标识符。

  • enableForeignKeySQL() public

    获取用于启用外键的 SQL。

  • enabled() public

    返回 php 是否能够使用此驱动程序连接到数据库

  • exec() public

    使用内部 PDO 实例执行 SQL 查询。

  • execute() public

    使用 $params 执行查询以插入值,并使用 $types 作为这些 params 的提示。

  • executeStatement() protected

    执行语句并记录查询字符串。

  • getLogger() public

    获取日志记录器实例。

  • getMaxAliasLength() public

    返回允许的最大别名长度。

  • getPdo() protected

    获取 PDO 连接实例。

  • getResultSetDecorators() protected

    返回要在选择查询的情况下应用于结果集的装饰器。

  • getRole() public

    返回此驱动程序执行的连接角色。

  • inTransaction() public

    返回连接是否处于活动事务中。

  • isAutoQuotingEnabled() public

    返回此驱动程序是否应在查询中自动引用标识符。

  • isConnected() public

    检查驱动程序是否已连接。

  • lastInsertId() public

    返回为数据库中的表或序列生成的最后 ID。

  • log() public

    使用配置的日志记录器对象记录消息或查询。

  • newCompiler() public
  • newTableSchema() public

    构造新的 TableSchema。

  • prepare() public

    准备要执行的 sql 语句。

  • quoteIdentifier() public

    引用数据库标识符(列名、表名等)以安全地在查询中使用,避免使用保留字的风险。

  • quoter() public

    获取标识符引用器实例。

  • releaseSavePointSQL() public

    返回释放先前创建的保存点的 SQL 代码片段。

  • rollbackSavePointSQL() public

    返回回滚先前创建的保存点的 SQL 代码片段。

  • rollbackTransaction() public

    回滚事务。

  • run() public

    在为特定驱动程序方言编译后执行提供的查询,并返回执行的 Statement 对象。

  • savePointSQL() public

    返回创建新事务保存点的 SQL 代码片段。

  • schema() public

    返回正在使用的模式名称。

  • schemaDialect() public

    获取模式方言。

  • schemaValue() public

    转义模式定义中使用的值。

  • setEncoding() public

    设置连接编码。

  • setLogger() public

    设置日志记录器。

  • setSchema() public

    设置连接默认模式,如果查询中定义的任何关系没有完全限定,postgres 将回退到在定义的默认模式中查找关系。

  • supports() public

    返回驱动程序是否支持该功能。

  • transformQuery() protected

    转换查询以适应正在使用的 SQL 方言的任何特殊性。

  • version() public

    返回连接的服务器版本。

方法详情

__construct() ¶ public

__construct(array<string, mixed> $config = [])

构造函数

参数
array<string, mixed> $config optional

驱动程序的配置。

抛出
InvalidArgumentException

__debugInfo() ¶ public

__debugInfo(): array<string, mixed>

返回一个数组,可用于描述此对象的内部状态。

返回
array<string, mixed>

__destruct() ¶ public

__destruct()

析构函数

_deleteQueryTranslator() ¶ protected

_deleteQueryTranslator(Cake\Database\Query\DeleteQuery $query): Cake\Database\Query\DeleteQuery

将翻译步骤应用于删除查询。

从删除查询条件中剔除别名,因为大多数数据库方言不支持删除查询中的别名。这也从表名中删除别名,因为它们通常也不起作用。

我们故意不支持使用联接的删除,因为它们的兼容性更差。

参数
Cake\Database\Query\DeleteQuery $query

要转换的查询。

返回
Cake\Database\Query\DeleteQuery

_expressionTranslators() ¶ protected

_expressionTranslators(): array<class-string, string>

返回一个关联数组,其中包含将 Expression 对象转换为符合特定 SQL 方言的方法。键是类名,值是此类中的方法。

返回
array<class-string, string>

_insertQueryTranslator() ¶ protected

_insertQueryTranslator(Cake\Database\Query\InsertQuery $query): Cake\Database\Query\InsertQuery

将翻译步骤应用于插入查询。

参数
Cake\Database\Query\InsertQuery $query
返回
Cake\Database\Query\InsertQuery

_removeAliasesFromConditions() ¶ protected

_removeAliasesFromConditions(Cake\Database\Query\UpdateQueryCake\Database\Query\DeleteQuery $query): Cake\Database\Query\UpdateQueryCake\Database\Query\DeleteQuery

从查询的 WHERE 子句中删除别名。

参数
Cake\Database\Query\UpdateQueryCake\Database\Query\DeleteQuery $query

要处理的查询。

返回
Cake\Database\Query\UpdateQueryCake\Database\Query\DeleteQuery
抛出
Cake\Database\Exception\DatabaseException
如果处理过的查询包含任何联接,因为从条件中删除别名可能会破坏对联接表的引用。

_selectQueryTranslator() ¶ protected

_selectQueryTranslator(Cake\Database\Query\SelectQuery<mixed> $query): Cake\Database\Query\SelectQuery<mixed>

将翻译步骤应用于选择查询。

参数
Cake\Database\Query\SelectQuery<mixed> $query

要转换的查询。

返回
Cake\Database\Query\SelectQuery<mixed>

_transformDistinct() ¶ protected

_transformDistinct(Cake\Database\Query\SelectQuery<mixed> $query): Cake\Database\Query\SelectQuery<mixed>

在重写 DISTINCT 子句后返回传递的查询,以便不支持“ON”部分的驱动程序可以提供实际执行方式

参数
Cake\Database\Query\SelectQuery<mixed> $query
返回
Cake\Database\Query\SelectQuery<mixed>

_transformFunctionExpression() ¶ protected

_transformFunctionExpression(Cake\Database\Expression\FunctionExpression $expression): void

接收 FunctionExpression 并对其进行更改,使其符合此 SQL 方言。

参数
Cake\Database\Expression\FunctionExpression $expression

要转换为 postgres SQL 的函数表达式。

返回
void

_transformIdentifierExpression() ¶ protected

_transformIdentifierExpression(Cake\Database\Expression\IdentifierExpression $expression): void

将标识符表达式更改为 postgresql 格式。

参数
Cake\Database\Expression\IdentifierExpression $expression

要转换的表达式。

返回
void

_transformStringExpression() ¶ protected

_transformStringExpression(Cake\Database\Expression\StringExpression $expression): void

将字符串表达式更改为 postgresql 格式。

参数
Cake\Database\Expression\StringExpression $expression

要转换的字符串表达式。

返回
void

_updateQueryTranslator() ¶ protected

_updateQueryTranslator(Cake\Database\Query\UpdateQuery $query): Cake\Database\Query\UpdateQuery

将翻译步骤应用于更新查询。

从更新查询条件中剔除别名,因为并非所有数据库方言都支持更新查询中的别名。

与删除查询一样,当前不支持更新查询的联接。

参数
Cake\Database\Query\UpdateQuery $query

要转换的查询。

返回
Cake\Database\Query\UpdateQuery

beginTransaction() ¶ public

beginTransaction(): bool

开始事务。

返回
bool

commitTransaction() ¶ public

commitTransaction(): bool

提交事务。

返回
bool

compileQuery() ¶ public

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

将传递的查询转换为此驱动程序的方言,并返回已转换查询的实例以及完全编译的 SQL 字符串。

参数
Cake\Database\Query $query

要编译的查询。

Cake\Database\ValueBinder $binder

要使用的值绑定器。

返回
string

config() ¶ public

config(): array<string, mixed>

获取用于创建驱动程序的配置数据。

返回
array<string, mixed>

connect() ¶ public

connect(): void

建立与数据库服务器的连接。

返回
void

createLogger() ¶ protected

createLogger(string|null $className): Psr\Log\LoggerInterface

创建日志记录器实例。

参数
string|null $className

日志记录器的类名。

返回
Psr\Log\LoggerInterface

createPdo() ¶ protected

createPdo(string $dsn, array<string, mixed> $config): PDO

建立与数据库服务器的连接

参数
string $dsn

特定于驱动程序的 PDO-DSN。

array<string, mixed> $config

用于创建连接的配置。

返回
PDO

createQueryException() ¶ protected

createQueryException(PDOException $exception, Cake\Database\StatementInterface $statement, array|null $params = null): Cake\Database\Exception\QueryException

从 PDOException 创建 QueryException

参数
PDOException $exception
Cake\Database\StatementInterface $statement
array|null $params optional
返回
Cake\Database\Exception\QueryException

disableAutoQuoting() ¶ public

disableAutoQuoting(): $this

禁用查询中标识符的自动引用。

返回
$this

disableForeignKeySQL() ¶ public

disableForeignKeySQL(): string

获取用于禁用外键的 SQL。

返回
string

disconnect() ¶ public

disconnect(): void

断开与数据库服务器的连接。

返回
void

enableAutoQuoting() ¶ public

enableAutoQuoting(bool $enable = true): $this

设置此驱动程序是否应在查询中自动引用标识符。

参数
bool $enable optional

是否启用自动引用。

返回
$this

enableForeignKeySQL() ¶ public

enableForeignKeySQL(): string

获取用于启用外键的 SQL。

返回
string

enabled() ¶ public

enabled(): bool

返回 php 是否能够使用此驱动程序连接到数据库

返回
bool

exec() ¶ public

exec(string $sql): int|false

使用内部 PDO 实例执行 SQL 查询。

参数
string $sql

SQL 查询。

返回
int|false

execute() ¶ public

execute(string $sql, array $params = [], array $types = []): Cake\Database\StatementInterface

使用 $params 执行查询以插入值,并使用 $types 作为这些 params 的提示。

参数
string $sql

要执行并使用 $params 进行插值的 SQL。

array $params optional

要插值到 $sql 中作为值的参数列表或关联数组。

array $types optional

用于在查询中转换值的类型列表或关联数组。

返回
Cake\Database\StatementInterface

executeStatement() ¶ protected

executeStatement(Cake\Database\StatementInterface $statement, array|null $params = null): void

执行语句并记录查询字符串。

参数
Cake\Database\StatementInterface $statement

要执行的语句。

array|null $params optional

要绑定到查询的值列表。

返回
void

getLogger() ¶ public

getLogger(): Psr\Log\LoggerInterface|null

获取日志记录器实例。

返回
Psr\Log\LoggerInterface|null

getMaxAliasLength() ¶ public

getMaxAliasLength(): int|null

返回允许的最大别名长度。

这可能与列的最大标识符长度不同。

返回
int|null

getPdo() ¶ protected

getPdo(): PDO

获取 PDO 连接实例。

返回
PDO

getResultSetDecorators() ¶ protected

getResultSetDecorators(Cake\Database\Query|string $query): arrayClosure>

返回要在选择查询的情况下应用于结果集的装饰器。

参数
Cake\Database\Query|string $query

要装饰的查询。

返回
arrayClosure>

getRole() ¶ public

getRole(): string

返回此驱动程序执行的连接角色。

返回
string

inTransaction() ¶ public

inTransaction(): bool

返回连接是否处于活动事务中。

返回
bool

isAutoQuotingEnabled() ¶ public

isAutoQuotingEnabled(): bool

返回此驱动程序是否应在查询中自动引用标识符。

返回
bool

isConnected() ¶ public

isConnected(): bool

检查驱动程序是否已连接。

返回
bool

lastInsertId() ¶ public

lastInsertId(string|null $table = null): string

返回为数据库中的表或序列生成的最后 ID。

参数
string|null $table 可选

获取最后插入值的表名或序列。

返回
string

log() ¶ public

log(Stringable|string $message, array $context = []): bool

使用配置的日志记录器对象记录消息或查询。

参数
Stringable|string $message

消息字符串或查询。

array $context 可选

日志记录上下文。

返回
bool

newCompiler() ¶ public

newCompiler(): Cake\Database\PostgresCompiler
返回
Cake\Database\PostgresCompiler

newTableSchema() ¶ public

newTableSchema(string $table, array<string, mixed> $columns = []): Cake\Database\Schema\TableSchemaInterface

构造新的 TableSchema。

参数
string $table

表名。

array<string, mixed> $columns 可选

架构的列列表。

返回
Cake\Database\Schema\TableSchemaInterface

prepare() ¶ public

prepare(Cake\Database\Query|string $query): Cake\Database\StatementInterface

准备要执行的 sql 语句。

参数
Cake\Database\Query|string $query

要转换为预处理语句的查询。

返回
Cake\Database\StatementInterface

quoteIdentifier() ¶ public

quoteIdentifier(string $identifier): string

引用数据库标识符(列名、表名等)以安全地在查询中使用,避免使用保留字的风险。

参数
string $identifier

要引用的标识符。

返回
string

quoter() ¶ public

quoter(): Cake\Database\IdentifierQuoter

获取标识符引用器实例。

返回
Cake\Database\IdentifierQuoter

releaseSavePointSQL() ¶ public

releaseSavePointSQL(string|int $name): string

返回释放先前创建的保存点的 SQL 代码片段。

参数
string|int $name

保存点名称

返回
string

rollbackSavePointSQL() ¶ public

rollbackSavePointSQL(string|int $name): string

返回回滚先前创建的保存点的 SQL 代码片段。

参数
string|int $name

保存点名称

返回
string

rollbackTransaction() ¶ public

rollbackTransaction(): bool

回滚事务。

返回
bool

run() ¶ public

run(Cake\Database\Query $query): Cake\Database\StatementInterface

在为特定驱动程序方言编译后执行提供的查询,并返回执行的 Statement 对象。

参数
Cake\Database\Query $query

要执行的查询。

返回
Cake\Database\StatementInterface

savePointSQL() ¶ public

savePointSQL(string|int $name): string

返回创建新事务保存点的 SQL 代码片段。

参数
string|int $name

保存点名称

返回
string

schema() ¶ public

schema(): string

返回正在使用的模式名称。

返回
string

schemaDialect() ¶ public

schemaDialect(): Cake\Database\Schema\SchemaDialect

获取模式方言。

用于 {@link \Cake\Database\Schema} 包来反映架构和生成架构。

如果所有使用此驱动程序的表都指定了自己的架构,那么这可能会返回 null。

返回
Cake\Database\Schema\SchemaDialect

schemaValue() ¶ public

schemaValue(mixed $value): string

转义模式定义中使用的值。

参数
mixed $value

要转义的值。

返回
string

setEncoding() ¶ public

setEncoding(string $encoding): void

设置连接编码。

参数
string $encoding

要使用的编码。

返回
void

setLogger() ¶ public

setLogger(LoggerInterface $logger): void

设置日志记录器。

参数
LoggerInterface $logger
返回
void

setSchema() ¶ public

setSchema(string $schema): void

设置连接默认模式,如果查询中定义的任何关系没有完全限定,postgres 将回退到在定义的默认模式中查找关系。

参数
string $schema

要设置为 search_path 的架构名称。

返回
void

supports() ¶ public

supports(Cake\Database\DriverFeatureEnum $feature): bool

返回驱动程序是否支持该功能。

对于未知功能应返回 false。

参数
Cake\Database\DriverFeatureEnum $feature
返回
bool

transformQuery() ¶ protected

transformQuery(Cake\Database\Query $query): Cake\Database\Query

转换查询以适应正在使用的 SQL 方言的任何特殊性。

如果启用了自动引用,它还会引用标识符。

参数
Cake\Database\Query $query

要转换的查询。

返回
Cake\Database\Query

version() ¶ public

version(): string

返回连接的服务器版本。

返回
string

属性详情

$_autoQuoting ¶ protected

指示驱动程序是否对所有查询进行自动标识符引用

Type
bool

$_baseConfig ¶ protected

Postgres 驱动程序的基本配置设置

Type
array<string, mixed>

$_config ¶ protected

配置数据。

Type
array<string, mixed>

$_endQuote ¶ protected

用于结束数据库标识符引用的字符串,以使其安全

Type
string

$_schemaDialect ¶ protected

此驱动程序的模式方言

Type
Cake\Database\Schema\SchemaDialect

$_startQuote ¶ protected

用于开始数据库标识符引用的字符串,以使其安全

Type
string

$_version ¶ protected

服务器版本

Type
string|null

$connectRetries ¶ protected

最后一次连接重试尝试次数。

Type
int

$logger ¶ protected

日志记录器实例。

Type
?LoggerInterface

$pdo ¶ protected

PDO 实例。

Type
PDO|null

$quoter ¶ protected

标识符引用器

Type
Cake\Database\IdentifierQuoter|null
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题 (Github)
  • 面包店
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻
  • LinkedIn
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成