Skip to content

Commit

Permalink
PgSqlDriver: uses cache for getColumnTypes() to avoid excessive numbe…
Browse files Browse the repository at this point in the history
…r of queries [Closes #212]
  • Loading branch information
dg committed Nov 20, 2018
1 parent 7c08500 commit 7c0113d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Database/Drivers/PgSqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ public function getForeignKeys(string $table): array

public function getColumnTypes(\PDOStatement $statement): array
{
return Nette\Database\Helpers::detectTypes($statement);
static $cache;
$item = &$cache[$statement->queryString];
if ($item === null) {
$item = Nette\Database\Helpers::detectTypes($statement);
}
return $item;
}


Expand Down

0 comments on commit 7c0113d

Please sign in to comment.