31 lines
845 B
PHP
31 lines
845 B
PHP
<?php
|
|
|
|
namespace Core\lib;
|
|
|
|
class PDOPool extends DBPool
|
|
{
|
|
public function __construct($min = 5, $max = 10)
|
|
{
|
|
global $GLOBAL_CONFIGS;
|
|
$poolconfig = $GLOBAL_CONFIGS["dbpool"]["default"];
|
|
parent::__construct($poolconfig['min'], $poolconfig['max']);
|
|
//\Swoole\Runtime::enableCoroutine(true);
|
|
}
|
|
|
|
protected function newDB()
|
|
{
|
|
global $GLOBAL_CONFIGS;
|
|
$default = $GLOBAL_CONFIGS["db"]["default"];
|
|
{
|
|
$driver = $default["driver"];
|
|
$host = $default["host"];
|
|
$dbname = $default['database'];
|
|
$username = $default["username"];
|
|
$password = $default["password"];
|
|
$dsn = "$driver:host=$host;dbname=$dbname";
|
|
}
|
|
|
|
$pdo = new \PDO($dsn, $username, $password);
|
|
return $pdo;
|
|
}
|
|
} |