Skip to content

Commit bd13e76

Browse files
committed
Doctrine - reworked resolving of connection name to be done only once and work with all DBAL versions.
1 parent 8bfcaf4 commit bd13e76

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Clockwork/DataSource/DBALDataSource.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ class DBALDataSource extends DataSource implements SQLLogger
2020
// DBAL connection
2121
protected $connection;
2222

23+
// DBAL connection name
24+
protected $connectionName;
25+
2326
// Create a new data source instance, takes a DBAL connection instance as an argument
2427
public function __construct(Connection $connection)
2528
{
2629
$this->connection = $connection;
30+
$this->connectionName = $this->connection->getDatabase();
2731

2832
$configuration = $this->connection->getConfiguration();
2933
$currentLogger = $configuration->getSQLLogger();
@@ -79,9 +83,7 @@ protected function registerQuery($query)
7983
'query' => $this->createRunnableQuery($query['query'], $query['params'], $query['types']),
8084
'bindings' => $query['params'],
8185
'duration' => (microtime(true) - $query['time']) * 1000,
82-
// Resolve connection only on DBAL versions older that 3.0, as resolving connection on newer DBAL always
83-
// executes an additional SQL query, effectively doubling the number of executed queries
84-
'connection' => class_exists(Doctrine\DBAL\DBALException::class) ? $this->connection->getDatabase() : null,
86+
'connection' => $this->connectionName,
8587
'time' => $query['time']
8688
];
8789

0 commit comments

Comments
 (0)