# \PG\MSF\PoolsMysqlAsynPool

Class MysqlAsynPool

## Summary

Methods
Properties
Constants
__construct()
addTokenCallback()
distribute()
serverInit()
workerInit()
pushToPool()
getSync()
getDBQueryBuilder()
execute()
prepareOne()
reconnect()
freeBind()
onClose()
getAsynName()
begin()
bind()
query()
coroutineBegin()
commit()
coroutineCommit()
rollback()
coroutineRollback()
$config
$dbQueryBuilder
$bindPool
MAX_TOKEN
ASYN_NAME
No protected methods found
$commands
$pool
$callBacks
$workerId
$server
$swooleServer
$token
$waitConnectNum
$asynManager
$mysqlMaxCount
N/A
No private methods found
$active
$mysqlClient
N/A

File
  Pools/MysqlAsynPool.php
Package
  MSF\Pools
Class hierarchy
  \PG\MSF\Pools\AsynPool
  \PG\MSF\Pools\MysqlAsynPool
Uses traits
  \PG\AOP\MI

## Tags

None found

## Constants

### MAX_TOKEN

    MAX_TOKEN

TOKEN最大值

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### ASYN_NAME

    ASYN_NAME

连接池类型名称

#

## Tags

None found

## Properties

### $config

    $config : \Noodlehaus\Config

#### Type

\Noodlehaus\Config — 配置对象

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $dbQueryBuilder

    $dbQueryBuilder : \PG\MSF\Pools\Miner

#### Type

\PG\MSF\Pools\Miner — SQL Builder

#

## Tags

None found

### $bindPool

    $bindPool : array

#### Type

array — 绑定的连接映射表

#

## Tags

None found

### $commands

    $commands : \SplQueue

#### Type

\SplQueue — 待执行命令队列

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $pool

    $pool : \SplQueue

#### Type

\SplQueue — 连接池

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $callBacks

    $callBacks : array

#### Type

array — 回调函数

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $workerId

    $workerId : integer

#### Type

integer — worker进程ID

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $server

    $server : \swoole_server

#### Type

\swoole_server — swoole_server实例

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $swooleServer

    $swooleServer : \PG\MSF\MSFServer

#### Type

\PG\MSF\MSFServer — server运行实例

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $token

    $token : integer

#### Type

integer — 回调Token

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $waitConnectNum

    $waitConnectNum : integer

#### Type

integer — 待连接数量

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $asynManager

    $asynManager : \PG\MSF\Pools\AsynPoolManager

#### Type

\PG\MSF\Pools\AsynPoolManager — 连接池管理器

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $mysqlMaxCount

    $mysqlMaxCount : integer

#### Type

integer — 连接峰值

#

## Tags

None found

### $active

    $active : string

#### Type

string — 连接池标识

#

## Tags

None found

### $mysqlClient

    $mysqlClient : \PG\MSF\Pools\Miner

#### Type

\PG\MSF\Pools\Miner — 同步MySQL客户端

#

## Tags

None found

## Methods

### __construct()

    __construct(\Noodlehaus\Config  $config, string  $active)

MysqlAsynPool constructor.

#### Parameters

\Noodlehaus\Config | $config | 配置对象
string | $active | 连接池名称

#

## Tags

None found

### addTokenCallback()

    addTokenCallback(callable  $callback) : integer

注册回调

#### Parameters

callable | $callback | 回调函数

#### Returns

integer

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### distribute()

    distribute(array  $data) : $this

分发消息

#### Parameters

array | $data | 待分发数据

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### serverInit()

    serverInit(\PG\MSF\MSFServer  $swooleServer, \PG\MSF\Pools\AsynPoolManager  $asynManager) : $this

初始化

#### Parameters

\PG\MSF\MSFServer | $swooleServer | Server实例
\PG\MSF\Pools\AsynPoolManager | $asynManager | 异步连接池管理器

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### workerInit()

    workerInit(integer  $workerId) : $this

初始化workerId

#### Parameters

integer | $workerId | worker进程ID

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### pushToPool()

    pushToPool(mixed  $client) : $this

归还连接

#### Parameters

mixed | $client | 连接对象

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### getSync()

    getSync() : \PG\MSF\Pools\Miner

获取同步

#### Returns

\PG\MSF\Pools\Miner

#

## Tags

None found

### getDBQueryBuilder()

    getDBQueryBuilder(\PG\MSF\Helpers\Context  $context = null) : \PG\MSF\Pools\Miner

获取DB Query Builder

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象

#### Returns

\PG\MSF\Pools\Miner

#

## Tags

None found

### execute()

    execute(array  $data)

执行MySQL SQL

#### Parameters

array | $data | 执行的SQL信息

#### Throws

\Exception

#

## Tags

None found

### prepareOne()

    prepareOne()

创建一个Mysql连接

#

## Tags

None found

### reconnect()

    reconnect(\swoole_mysql|null  $client = null)

重连或者连接

#### Parameters

\swoole_mysql|null | $client | MySQL连接对象

#

## Tags

None found

### freeBind()

    freeBind(\PG\MSF\Helpers\Context  $context, integer  $bindId)

释放绑定

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
integer | $bindId | bind ID

#

## Tags

None found

### onClose()

    onClose(\swoole_mysql  $client)

断开链接

#### Parameters

\swoole_mysql | $client | MySQL连接对象

#

## Tags

None found

### getAsynName()

    getAsynName() : string

返回唯一的连接池名称

#### Returns

string

#

## Tags

None found

### begin()

    begin(\PG\MSF\Helpers\Context  $context, mixed  $object, callable  $callback) : string

开启一个事务

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
mixed | $object | 绑定对象
callable | $callback | 执行完成后的回调函数

#### Returns

string

#

## Tags

None found

### bind()

    bind(\PG\MSF\Helpers\Context  $context, mixed  $object) : string

获取绑定值

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
mixed | $object | 绑定对象

#### Returns

string

#

## Tags

None found

### query()

    query(\PG\MSF\Helpers\Context  $context, callable  $callback, integer|null  $bindId = null, string|null  $sql = null)

执行一个sql语句

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
callable | $callback | 执行完成后的回调函数
integer|null | $bindId | 绑定ID
string|null | $sql | SQL语句

#### Throws

\Exception

#

## Tags

None found

### coroutineBegin()

    coroutineBegin(\PG\MSF\Helpers\Context  $context, mixed  $object) : \PG\MSF\Pools\MySql

开启一个协程事务

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
mixed | $object | 绑定对象

#### Returns

\PG\MSF\Pools\MySql

#

## Tags

None found

### commit()

    commit(\PG\MSF\Helpers\Context  $context, string  $callback, integer  $id)

提交一个事务

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
string | $callback | 执行完成后的回调函数
integer | $id | 绑定ID

#

## Tags

None found

### coroutineCommit()

    coroutineCommit(\PG\MSF\Helpers\Context  $context, integer  $id) : \PG\MSF\Pools\MySql

协程Commit

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
integer | $id | 绑定ID

#### Returns

\PG\MSF\Pools\MySql

#

## Tags

None found

### rollback()

    rollback(\PG\MSF\Helpers\Context  $context, callable  $callback, integer  $id)

回滚

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
callable | $callback | 执行完成后的回调函数
integer | $id | 绑定ID

#

## Tags

None found

### coroutineRollback()

    coroutineRollback(\PG\MSF\Helpers\Context  $context, integer  $id) : \PG\MSF\Pools\MySql

协程Rollback

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象
integer | $id | 绑定ID

#### Returns

\PG\MSF\Pools\MySql

#

## Tags

None found

### MysqlAsynPool.php