Cache created adapter.
This commit is contained in:
parent
e890aece71
commit
fecf280f74
1 changed files with 7 additions and 1 deletions
|
|
@ -15,6 +15,8 @@ class Database
|
||||||
private string $database;
|
private string $database;
|
||||||
private string $charset = 'utf8mb4';
|
private string $charset = 'utf8mb4';
|
||||||
|
|
||||||
|
private ?Adapter $adapter = null;
|
||||||
|
|
||||||
public function __construct(string $name = null, array $config = null)
|
public function __construct(string $name = null, array $config = null)
|
||||||
{
|
{
|
||||||
if ($name) {
|
if ($name) {
|
||||||
|
|
@ -182,7 +184,11 @@ class Database
|
||||||
|
|
||||||
public function getAdapter(): Adapter
|
public function getAdapter(): Adapter
|
||||||
{
|
{
|
||||||
return new Adapter($this->getArray());
|
if (!$this->adapter) {
|
||||||
|
$this->adapter = new Adapter($this->getArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMetadata(): Metadata
|
public function getMetadata(): Metadata
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue