PDO 类
(PHP 5 >= 5.1.0, PHP 7, PHP 8, PECL pdo >= 0.1.0)
简介
代表 PHP 和数据库服务之间的连接
类摘要
class PDO
{
/* 常量 */
/* 方法 */
public __construct(
string
?string
#[\SensitiveParameter] ?string
?array
)
string
$dsn,?string
$username = null,#[\SensitiveParameter] ?string
$password = null,?array
$options = null)
public static connect(
string
?string
#[\SensitiveParameter] ?string
?array
): static
}string
$dsn,?string
$username = null,#[\SensitiveParameter] ?string
$password = null,?array
$options = null): static
更新日志
| 版本 | 说明 |
|---|---|
| 8.4.0 | 类常量现已类型化。 |
目录
- PDO::beginTransaction — 启动一个事务
- PDO::commit — 提交一个事务
- PDO::connect — Connect to a database and return a PDO subclass for drivers that support it
- PDO::__construct — 创建一个表示数据库连接的 PDO 实例
- PDO::errorCode — 获取跟数据库句柄上一次操作相关的 SQLSTATE
- PDO::errorInfo — Fetch extended error information associated with the last operation on the database handle
- PDO::exec — 执行 SQL 语句,并返回受影响的行数
- PDO::getAttribute — 取回一个数据库连接的属性
- PDO::getAvailableDrivers — 返回一个可用驱动的数组
- PDO::inTransaction — 检查是否在事务内
- PDO::lastInsertId — 返回最后插入行的ID或序列值
- PDO::prepare — 预处理要执行的语句,并返回语句对象
- PDO::query — 预处理并执行没有占位符的 SQL 语句
- PDO::quote — 为 SQL 查询里的字符串添加引号
- PDO::rollBack — 回滚事务
- PDO::setAttribute — 设置属性