mirror of
https://github.com/dg/dibi.git
synced 2025-08-02 20:27:35 +02:00
Partially reverts "DibiTranslator: object is initialized in constructor", fixes lazy connection [Closes #138]
This reverts commit 0071b80938
.
This commit is contained in:
@@ -51,7 +51,6 @@ final class DibiTranslator extends DibiObject
|
||||
public function __construct(DibiConnection $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->driver = $connection->getDriver();
|
||||
$this->identifiers = new DibiHashMap(array($this, 'delimite'));
|
||||
}
|
||||
|
||||
@@ -64,6 +63,10 @@ final class DibiTranslator extends DibiObject
|
||||
*/
|
||||
public function translate(array $args)
|
||||
{
|
||||
if (!$this->driver) {
|
||||
$this->driver = $this->connection->getDriver();
|
||||
}
|
||||
|
||||
$args = array_values($args);
|
||||
while (count($args) === 1 && is_array($args[0])) { // implicit array expansion
|
||||
$args = array_values($args[0]);
|
||||
@@ -187,6 +190,10 @@ final class DibiTranslator extends DibiObject
|
||||
return "...";
|
||||
}
|
||||
|
||||
if (!$this->driver) {
|
||||
$this->driver = $this->connection->getDriver();
|
||||
}
|
||||
|
||||
// array processing (with or without modifier)
|
||||
if ($value instanceof Traversable) {
|
||||
$value = iterator_to_array($value);
|
||||
|
Reference in New Issue
Block a user