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
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
    • 数据库
      • 驱动
      • 异常
      • 表达式
      • 日志
      • 查询
      • 重试
      • 模式
      • 语句
      • 类型
    • 数据源
    • 错误
    • 事件
    • 表单
    • Http
    • I18n
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用程序
    • 验证
    • 视图

Sqlite 类

Sqlite 类

命名空间: Cake\Database\Driver

常量

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

属性概要

  • $_autoQuoting protected
    bool

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

  • $_baseConfig protected
    array<string, mixed>

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

  • $_config protected
    array<string, mixed>

    配置数据。

  • $_dateParts protected
    array<string, string>

    日期部分的映射。

  • $_endQuote protected
    string

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

  • $_schemaDialect protected
    Cake\Database\Schema\SchemaDialect

    此驱动程序的模式方言

  • $_startQuote protected
    string

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

  • $_supportsWindowFunctions protected
    bool|null

    连接的服务器是否支持窗口函数。

  • $_version protected
    string|null

    服务器版本

  • $connectRetries protected
    int

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

  • $featureVersions protected
    array<string, string>

    功能到数据库服务器版本的映射,用于功能可用性检查。

  • $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 方言。

  • _transformTupleComparison() protected

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

  • _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 作为每个这些参数的提示。

  • executeStatement() protected

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

  • getLogger() public

    获取日志记录实例。

  • getMaxAliasLength() public

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

  • getPdo() protected

    获取 PDO 连接实例。

  • getResultSetDecorators() protected

    返回要应用于结果集的装饰器,以防是 SelectQuery。

  • 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

    转义用于模式定义的值。

  • setLogger() public

    设置日志记录器。

  • 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

要转换为TSQL的函数表达式。

返回
void

_transformTupleComparison() ¶ protected

_transformTupleComparison(Cake\Database\Expression\TupleComparison $expression, Cake\Database\Query $query): void

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

它将类似于'(a, b) IN ((c, d), (e, f))'的表达式转换为等效表达式,形式为'((a = c) AND (b = d)) OR ((a = e) AND (b = f))'。

它还可以转换表达式,其中右侧是一个查询,该查询选择的列数与表达式左侧元素的数量相同

(a, b) IN (SELECT c, d FROM a_table) 转换为

1 = (SELECT 1 FROM a_table WHERE (a = c) AND (b = d))

参数
Cake\Database\Expression\TupleComparison $expression

要转换的表达式

Cake\Database\Query $query

要更新的查询。

返回
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 作为每个这些参数的提示。

参数
string $sql

要执行的SQL以及使用$params进行插值

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() ¶ 受保护

getPdo(): PDO

获取 PDO 连接实例。

返回
PDO

getResultSetDecorators() ¶ 受保护

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

返回要应用于结果集的装饰器,以防是 SelectQuery。

参数
Cake\Database\Query|string $query

要装饰的查询。

返回
arrayClosure>

getRole() ¶ 公共

getRole(): string

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

返回
string

inTransaction() ¶ 公共

inTransaction(): bool

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

返回
bool

isAutoQuotingEnabled() ¶ 公共

isAutoQuotingEnabled(): bool

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

返回
bool

isConnected() ¶ 公共

isConnected(): bool

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

返回
bool

lastInsertId() ¶ 公共

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

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

参数
string|null $table 可选

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

返回
string

log() ¶ 公共

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

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

参数
Stringable|string $message

消息字符串或查询。

array $context 可选

日志记录上下文。

返回
bool

newCompiler() ¶ 公共

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

newTableSchema() ¶ 公共

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

构造新的 TableSchema。

参数
string $table

表名。

array<string, mixed> $columns 可选

架构的列列表。

返回
Cake\Database\Schema\TableSchemaInterface

prepare() ¶ 公共

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

准备要执行的 sql 语句。

参数
Cake\Database\Query|string $query

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

返回
Cake\Database\StatementInterface

quoteIdentifier() ¶ 公共

quoteIdentifier(string $identifier): string

引用数据库标识符(列名、表名等),以便在查询中安全使用,而不会使用保留字的风险

参数
string $identifier

要引用的标识符。

返回
string

quoter() ¶ 公共

quoter(): Cake\Database\IdentifierQuoter

获取标识符引用器实例。

返回
Cake\Database\IdentifierQuoter

releaseSavePointSQL() ¶ 公共

releaseSavePointSQL(string|int $name): string

返回用于释放先前创建的保存点的 SQL 片段

参数
string|int $name

保存点名称

返回
string

rollbackSavePointSQL() ¶ 公共

rollbackSavePointSQL(string|int $name): string

返回用于回滚先前创建的保存点的 SQL 片段

参数
string|int $name

保存点名称

返回
string

rollbackTransaction() ¶ 公共

rollbackTransaction(): bool

回滚事务。

返回
bool

run() ¶ 公共

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

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

参数
Cake\Database\Query $query

要执行的查询。

返回
Cake\Database\StatementInterface

savePointSQL() ¶ 公共

savePointSQL(string|int $name): string

返回用于创建新事务保存点的 SQL 片段

参数
string|int $name

保存点名称

返回
string

schema() ¶ 公共

schema(): string

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

返回
string

schemaDialect() ¶ 公共

schemaDialect(): Cake\Database\Schema\SchemaDialect

获取模式方言。

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

如果所有使用此驱动的表都指定了自己的架构,则此方法可能返回 null。

返回
Cake\Database\Schema\SchemaDialect

schemaValue() ¶ 公共

schemaValue(mixed $value): string

转义用于模式定义的值。

参数
mixed $value

要转义的值。

返回
string

setLogger() ¶ 公共

setLogger(LoggerInterface $logger): void

设置日志记录器。

参数
LoggerInterface $logger
返回
void

supports() ¶ 公共

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

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

对于未知功能应返回 false。

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

transformQuery() ¶ 受保护

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

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

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

参数
Cake\Database\Query $query

要转换的查询。

返回
Cake\Database\Query

version() ¶ 公共

version(): string

返回连接的服务器版本。

返回
string

属性详情

$_autoQuoting ¶ 受保护

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

类型
bool

$_baseConfig ¶ 受保护

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

  • mask 用于创建数据库的掩码
类型
array<string, mixed>

$_config ¶ 受保护

配置数据。

类型
array<string, mixed>

$_dateParts ¶ 受保护

日期部分的映射。

类型
array<string, string>

$_endQuote ¶ 受保护

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

类型
string

$_schemaDialect ¶ 受保护

此驱动程序的模式方言

类型
Cake\Database\Schema\SchemaDialect

$_startQuote ¶ 受保护

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

类型
string

$_supportsWindowFunctions ¶ 受保护

连接的服务器是否支持窗口函数。

类型
bool|null

$_version ¶ 受保护

服务器版本

类型
string|null

$connectRetries ¶ 受保护

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

类型
int

$featureVersions ¶ 受保护

功能到数据库服务器版本的映射,用于功能可用性检查。

类型
array<string, string>

$logger ¶ 受保护

日志记录实例。

类型
?LoggerInterface

$pdo ¶ 受保护

PDO 实例。

类型
PDO|null

$quoter ¶ 受保护

标识符引用器

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

使用 CakePHP API 文档 生成