mirror of
https://github.com/dg/dibi.git
synced 2025-08-08 07:06:52 +02:00
This commit is contained in:
@@ -51,7 +51,7 @@ class Connection implements IConnection
|
|||||||
* - profiler (array)
|
* - profiler (array)
|
||||||
* - run (bool) => enable profiler?
|
* - run (bool) => enable profiler?
|
||||||
* - file => file to log
|
* - file => file to log
|
||||||
* - errorsOnly (bool) => log only errors
|
* - errorsOnly (bool) => log only errors
|
||||||
* - substitutes (array) => map of driver specific substitutes (under development)
|
* - substitutes (array) => map of driver specific substitutes (under development)
|
||||||
* - onConnect (array) => list of SQL queries to execute (by Connection::query()) after connection is established
|
* - onConnect (array) => list of SQL queries to execute (by Connection::query()) after connection is established
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -110,6 +110,7 @@ class Connection implements IConnection
|
|||||||
{
|
{
|
||||||
if ($this->config['driver'] instanceof Driver) {
|
if ($this->config['driver'] instanceof Driver) {
|
||||||
$this->driver = $this->config['driver'];
|
$this->driver = $this->config['driver'];
|
||||||
|
$this->translator = new Translator($this);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} elseif (is_subclass_of($this->config['driver'], Driver::class)) {
|
} elseif (is_subclass_of($this->config['driver'], Driver::class)) {
|
||||||
@@ -126,6 +127,8 @@ class Connection implements IConnection
|
|||||||
$event = $this->onEvent ? new Event($this, Event::CONNECT) : null;
|
$event = $this->onEvent ? new Event($this, Event::CONNECT) : null;
|
||||||
try {
|
try {
|
||||||
$this->driver = new $class($this->config);
|
$this->driver = new $class($this->config);
|
||||||
|
$this->translator = new Translator($this);
|
||||||
|
|
||||||
if ($event) {
|
if ($event) {
|
||||||
$this->onEvent($event->done());
|
$this->onEvent($event->done());
|
||||||
}
|
}
|
||||||
@@ -151,7 +154,7 @@ class Connection implements IConnection
|
|||||||
{
|
{
|
||||||
if ($this->driver) {
|
if ($this->driver) {
|
||||||
$this->driver->disconnect();
|
$this->driver->disconnect();
|
||||||
$this->driver = null;
|
$this->driver = $this->translator = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,11 +255,7 @@ class Connection implements IConnection
|
|||||||
if (!$this->driver) {
|
if (!$this->driver) {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
}
|
}
|
||||||
if (!$this->translator) {
|
return (clone $this->translator)->translate($args);
|
||||||
$this->translator = new Translator($this);
|
|
||||||
}
|
|
||||||
$translator = clone $this->translator;
|
|
||||||
return $translator->translate($args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user