Skip to content

Commit 7fc0c93

Browse files
author
Nil Portugués
committed
Defered nicely formatted queries, reducing memory consumption quite a bit
1 parent 5d18829 commit 7fc0c93

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/NilPortugues/SqlQueryBuilder/Builder/GenericBuilder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ class GenericBuilder implements BuilderInterface
8585
public function __construct()
8686
{
8787
$this->placeholderWriter = WriterFactory::createPlaceholderWriter();
88-
89-
$this->sqlFormatter = new Formatter();
9088
}
9189

9290
/**
@@ -255,6 +253,10 @@ public function write(QueryInterface $query, $resetPlaceholders = true)
255253
*/
256254
public function writeFormatted(QueryInterface $query)
257255
{
256+
if (false === ($this->sqlFormatter instanceof Formatter)) {
257+
$this->sqlFormatter = new Formatter();
258+
}
259+
258260
return $this->sqlFormatter->format($this->write($query));
259261
}
260262

0 commit comments

Comments
 (0)