Skip to content

Commit

Permalink
Defered nicely formatted queries, reducing memory consumption quite a…
Browse files Browse the repository at this point in the history
… bit
  • Loading branch information
Nil Portugués committed Sep 23, 2014
1 parent 5d18829 commit 7fc0c93
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/NilPortugues/SqlQueryBuilder/Builder/GenericBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class GenericBuilder implements BuilderInterface
public function __construct()
{
$this->placeholderWriter = WriterFactory::createPlaceholderWriter();

$this->sqlFormatter = new Formatter();
}

/**
Expand Down Expand Up @@ -255,6 +253,10 @@ public function write(QueryInterface $query, $resetPlaceholders = true)
*/
public function writeFormatted(QueryInterface $query)
{
if (false === ($this->sqlFormatter instanceof Formatter)) {
$this->sqlFormatter = new Formatter();
}

return $this->sqlFormatter->format($this->write($query));
}

Expand Down

0 comments on commit 7fc0c93

Please sign in to comment.