mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-07 08:45:37 +08:00
update to 2.5.0-b3 (build 410)
This commit is contained in:
37
src/ZM/MySQL/MySQLPool.php
Normal file
37
src/ZM/MySQL/MySQLPool.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php /** @noinspection PhpComposerExtensionStubsInspection */
|
||||
|
||||
/** @noinspection PhpReturnDocTypeMismatchInspection */
|
||||
|
||||
|
||||
namespace ZM\MySQL;
|
||||
|
||||
|
||||
use PDO;
|
||||
use Swoole\Database\PDOConfig;
|
||||
use Swoole\Database\PDOPool;
|
||||
use Swoole\Database\PDOProxy;
|
||||
|
||||
class MySQLPool extends PDOPool
|
||||
{
|
||||
private $count = 0;
|
||||
|
||||
public function __construct(PDOConfig $config, int $size = self::DEFAULT_SIZE) {
|
||||
parent::__construct($config, $size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PDO|PDOProxy|void
|
||||
*/
|
||||
public function getConnection() {
|
||||
$this->count++;
|
||||
return parent::get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PDO|PDOProxy $connection
|
||||
*/
|
||||
public function putConnection($connection) {
|
||||
$this->count--;
|
||||
parent::put($connection);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user