Properties

$handler

$handler : \think\db\ConnectionInterface

Type

\think\db\ConnectionInterface

$released

$released : \WeakMap

Type

\WeakMap —

$disconnected

$disconnected : \WeakMap

Type

\WeakMap —

$pool

$pool : \Smf\ConnectionPool\ConnectionPool

Type

\Smf\ConnectionPool\ConnectionPool —

Methods

__construct()

__construct(\Closure|\Smf\ConnectionPool\Connectors\ConnectorInterface  $connector, array  $config, array  $connectionConfig = []) : mixed

Proxy constructor.

Parameters

\Closure|\Smf\ConnectionPool\Connectors\ConnectorInterface $connector
array $config
array $connectionConfig

Returns

mixed —

release()

release() : mixed

Returns

mixed —

__call()

__call(mixed  $method, mixed  $arguments) : mixed

Parameters

mixed $method
mixed $arguments

Returns

mixed —

getQueryClass()

getQueryClass() : string

获取当前连接器类对应的Query类

Returns

string —

connect()

connect(array  $config = [], int  $linkNum) : mixed

连接数据库方法

Parameters

array $config

接参数

int $linkNum

连接序号

Returns

mixed —

setDb()

setDb(\think\DbManager  $db) : void

设置当前的数据库Db对象

Parameters

\think\DbManager $db

setCache()

setCache(\Psr\SimpleCache\CacheInterface  $cache) : void

设置当前的缓存对象

Parameters

\Psr\SimpleCache\CacheInterface $cache

getConfig()

getConfig(string  $config = '') : mixed

获取数据库的配置参数

Parameters

string $config

配置名称

Returns

mixed —

close()

close() : mixed

关闭数据库(或者重新连接)

Returns

mixed —

find()

find(\think\db\BaseQuery  $query) : array

查找单条记录

Parameters

\think\db\BaseQuery $query

查询对象

Returns

array —

select()

select(\think\db\BaseQuery  $query) : array

查找记录

Parameters

\think\db\BaseQuery $query

查询对象

Returns

array —

insert()

insert(\think\db\BaseQuery  $query, bool  $getLastInsID = false) : mixed

插入记录

Parameters

\think\db\BaseQuery $query

查询对象

bool $getLastInsID

返回自增主键

Returns

mixed —

insertAll()

insertAll(\think\db\BaseQuery  $query, array  $dataSet = []) : int

批量插入记录

Parameters

\think\db\BaseQuery $query

查询对象

array $dataSet

数据集

Throws

\Exception
\Throwable

Returns

int —

update()

update(\think\db\BaseQuery  $query) : int

更新记录

Parameters

\think\db\BaseQuery $query

查询对象

Returns

int —

delete()

delete(\think\db\BaseQuery  $query) : int

删除记录

Parameters

\think\db\BaseQuery $query

查询对象

Returns

int —

value()

value(\think\db\BaseQuery  $query, string  $field, mixed  $default = null) : mixed

得到某个字段的值

Parameters

\think\db\BaseQuery $query

查询对象

string $field

字段名

mixed $default

默认值

Returns

mixed —

column()

column(\think\db\BaseQuery  $query, string|array  $column, string  $key = '') : array

得到某个列的数组

Parameters

\think\db\BaseQuery $query

查询对象

string|array $column

字段名 多个字段用逗号分隔

string $key

索引

Returns

array —

transaction()

transaction(callable  $callback) : mixed

执行数据库事务

Parameters

callable $callback

数据操作方法回调

Throws

\Throwable

Returns

mixed —

startTrans()

startTrans() : void

启动事务

Throws

\Exception

commit()

commit() : void

用于非自动提交状态下面的查询提交

rollback()

rollback() : void

事务回滚

getLastSql()

getLastSql() : string

获取最近一次查询的sql语句

Returns

string —

table()

table(mixed  $table) : mixed

Parameters

mixed $table

Returns

mixed —

name()

name(mixed  $name) : mixed

Parameters

mixed $name

Returns

mixed —

getLastInsID()

getLastInsID(\think\db\BaseQuery  $query, ?string  $sequence = null) : mixed

Parameters

\think\db\BaseQuery $query
?string $sequence

Returns

mixed —

getTableFields()

getTableFields(string  $tableName) : array

Parameters

string $tableName

Returns

array —

getPoolConnection()

getPoolConnection() : mixed

Returns

mixed —

releaseConnection()

releaseConnection(mixed  $connection) : mixed

Parameters

mixed $connection

Returns

mixed —