   'phpDocumentor\Descriptor\FileDescriptor * hash 3a1f5135dc9e2ae74a4caff0bb107ab9 * pathCoroutine/MySql.php	 * source
k<?php
/**
 * MySql协程
 *
 * @author camera360_server@camera360.com
 * @copyright Chengdu pinguo Technology Co.,Ltd.
 */

namespace PG\MSF\Coroutine;

use Exception;
use PG\MSF\Pools\MysqlAsynPool;

/**
 * Class MySql
 * @package PG\MSF\Coroutine
 */
class MySql extends Base
{
    /**
     * @var MysqlAsynPool MySQL连接池对象
     */
    public $mysqlAsynPool;

    /**
     * @var string|null 绑定ID
     */
    public $bindId;

    /**
     * @var string|null 执行的SQL
     */
    public $sql;

    /**
     * MySql constructor.
     *
     * @param MysqlAsynPool $_mysqlAsynPool MySQL连接池对象
     * @param int|null $_bind_id bind ID
     * @param string|null $_sql 执行的SQL
     */
    public function __construct($_mysqlAsynPool, $_bind_id = null, $_sql = null)
    {
        parent::__construct();
        $this->mysqlAsynPool = $_mysqlAsynPool;
        $this->bindId        = $_bind_id;
        $this->sql           = $_sql;
        $this->request       = 'mysql(' . str_replace("\n", " ", $_sql) . ')';
        $this->requestId     = $this->getContext()->getLogId();

        $this->getContext()->getLog()->profileStart($this->request);
        getInstance()->scheduler->IOCallBack[$this->requestId][] = $this;
        $keys            = array_keys(getInstance()->scheduler->IOCallBack[$this->requestId]);
        $this->ioBackKey = array_pop($keys);

        $this->send(function ($result) {
            if ($this->isBreak) {
                return;
            }

            if (empty(getInstance()->scheduler->taskMap[$this->requestId])) {
                return;
            }

            $this->getContext()->getLog()->profileEnd($this->request);
            $this->result = $result;
            $this->ioBack = true;
            $this->nextRun();
        });
    }

    /**
     * 发送异步的MySQL请求
     *
     * @param callable $callback 执行SQL后的回调函数
     */
    public function send($callback)
    {
        $this->mysqlAsynPool->query($this->getContext(), $callback, $this->bindId, $this->sql);
    }

    /**
     * 获取执行结果
     *
     * @return mixed|null
     * @throws Exception
     */
    public function getResult()
    {
        $result = parent::getResult();
        if (is_array($result) && isset($result['error'])) {
            throw new Exception($result['error']);
        }
        return $result;
    }

    /**
     * 属性不用于序列化
     *
     * @return array
     */
    public function __unsleep()
    {
        return ['context', 'mysqlAsynPool'];
    }

    /**
     * 销毁
     */
    public function destroy()
    {
        parent::destroy();
    }
}
 * namespaceAliases#phpDocumentor\Descriptor\Collection * items	Exception
\ExceptionMysqlAsynPool\PG\MSF\Pools\MysqlAsynPool * includes	  * constants	  * functions	 
 * classes	\PG\MSF\Coroutine\MySql(phpDocumentor\Descriptor\ClassDescriptor	 * parent\PG\MSF\Coroutine\Base * implements	  * abstract * final	  * properties	mysqlAsynPool+phpDocumentor\Descriptor\PropertyDescriptor" * types 
 * default 	 * static * visibilitypublic * fqsen&\PG\MSF\Coroutine\MySql::mysqlAsynPool * name * namespace 
 * package
 * summary * description * fileDescriptor  * line * tags	var	 *phpDocumentor\Descriptor\Tag\VarDescriptor * variableName	 3phpDocumentor\Descriptor\Type\UnknownTypeDescriptor##+'MySQL连接池对象	 * errors	 0	  * inheritedElement bindId"   !\PG\MSF\Coroutine\MySql::bindId#2$ %&'( )*	+	 ,-	 .phpDocumentor\Descriptor\Type\StringDescriptor .#null#+'绑定ID0	 0	 1 sql"   !\PG\MSF\Coroutine\MySql::sql#7$ %&'( )!*	+	 ,-	 4 .#5#+'执行的SQL0	 0	 1 
 * methods	__construct)phpDocumentor\Descriptor\MethodDescriptor"  * arguments	$_mysqlAsynPool+phpDocumentor\Descriptor\ArgumentDescriptor	 * method"=	 .#  * byReference * isVariadic!#>$ %&'/( ) *	 0	 1 	$_bind_id?@"=	 /phpDocumentor\Descriptor\Type\IntegerDescriptor .#55AB!#C$ %&'bind ID( ) *	 0	 1 $_sql?@"=	 4 .#55AB!#F$ %&'9( ) *	 0	 1 !&\PG\MSF\Coroutine\MySql::__construct()#;$ %&MySql constructor.'( )**	param	 ,phpDocumentor\Descriptor\Tag\ParamDescriptor->"A#I'/0	 J-C"I#I'E0	 J-F"R#I'90	 return	 0	 1 send<" =		$callback?@"k	 .#callable AB!#M$ %&'执行SQL后的回调函数( ) *	 0	 1 !\PG\MSF\Coroutine\MySql::send()#L$ %&发送异步的MySQL请求'( )M*	I	 J-M"o#I'O0	 K	 0	 1 	getResult<" =	 !$\PG\MSF\Coroutine\MySql::getResult()#R$ %&获取执行结果'( )X*	K	 -phpDocumentor\Descriptor\Tag\ReturnDescriptor	 .#mixed.#5#K'0	 throws	 -phpDocumentor\Descriptor\Tag\ThrowsDescriptor	 .##W'0	 I	 0	 1 	__unsleep<" =	 !$\PG\MSF\Coroutine\MySql::__unsleep()#Y$ %&属性不用于序列化'( )f*	K	 U	 .#array#K'0	 I	 0	 1 destroy<" =	 !"\PG\MSF\Coroutine\MySql::destroy()#]$ %&销毁'( )n*	K	 I	 0	 1  * usedTraits	 !#MySql$\PG\MSF\Coroutine%PG\MSF\Coroutine&Class MySql'(" )*	package	 &phpDocumentor\Descriptor\TagDescriptor#e'c0	 
subpackage	 0	 1  * interfaces	 	 * traits	 
 * markers	 !#	MySql.php$ %Default&MySql协程'( ) *	author	 -phpDocumentor\Descriptor\Tag\AuthorDescriptor#n'camera360_server@camera360.com0	 	copyright	 f#q'"Chengdu pinguo Technology Co.,Ltd.0	 e	 f#e'l0	 g	 0	 1 