This commit is contained in:
2020-08-31 13:58:40 +08:00
parent 801c7dafc0
commit 814e73866e
4 changed files with 52 additions and 41 deletions
+3 -38
View File
@@ -40,18 +40,6 @@ class Connection extends Component
public $maxNumber = 100;
/**
* @var array
*
* @example [
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ]
*/
public $masterConfig = [];
/**
* @var bool
* enable database cache
@@ -63,10 +51,9 @@ class Connection extends Component
* @var array
*
* @example [
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* ['cds' => 'mysql:dbname=dbname;host=127.0.0.1', 'username' => 'root', 'password' => 'root'],
* 'cds' => 'mysql:dbname=dbname;host=127.0.0.1',
* 'username' => 'root',
* 'password' => 'root'
* ]
*/
public $slaveConfig = [];
@@ -186,28 +173,6 @@ class Connection extends Component
return $pool->getConnection($config, true);
}
/**
* @param $name
* @return Connection
* @throws ConfigException
*/
public function instance($name)
{
$config = Config::get('databases.' . $name, true);
$this->cds = $config['cds'];
$this->username = $config['username'];
$this->password = $config['password'];
$this->tablePrefix = $config['tablePrefix'];
$this->slaveConfig = $config['slaveConfig'];
return $this;
}
/**
* @return PDO
* @throws Exception