DDC-94: Queries executed through StandardEntityPersister load(), loadAll(), etc. are not logged. #115

Closed
opened 2026-01-22 12:27:26 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 1, 2009).

Jira issue originally created by user simonvdd:

In Doctrine\DBAL\Connection, execute() and executeUpdate() methods both call:
$this->_config->getSqlLogger()->logSql($query, $params)

But when you use the Doctrine\ORM\Persisters\StandardEntityPersister (which is the case with all magic repository methods in Symfony, such as Models\User::findAll() for example), it only calls the prepare() method of the Connection, so the query is not logged (and does not appear in the Debug Panel in Symfony for instance).

I added the following line in Doctrine\DBAL\Connection.php, in method prepare():
if ($this->_config->getSqlLogger()) {
$this->_config->getSqlLogger()->logSql($statement);
}
which seem to solve the problem in this case.

Originally created by @doctrinebot on GitHub (Nov 1, 2009). Jira issue originally created by user simonvdd: In Doctrine\DBAL\Connection, execute() and executeUpdate() methods both call: $this->_config->getSqlLogger()->logSql($query, $params) But when you use the Doctrine\ORM\Persisters\StandardEntityPersister (which is the case with all magic repository methods in Symfony, such as Models\User::findAll() for example), it only calls the prepare() method of the Connection, so the query is not logged (and does not appear in the Debug Panel in Symfony for instance). I added the following line in Doctrine\DBAL\Connection.php, in method prepare(): if ($this->_config->getSqlLogger()) { $this->_config->getSqlLogger()->logSql($statement); } which seem to solve the problem in this case.
admin added the Bug label 2026-01-22 12:27:26 +01:00
admin closed this issue 2026-01-22 12:27:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 1, 2009):

@doctrinebot commented on GitHub (Nov 1, 2009): - is referenced by [DDC-162: sqlLogger does not log everything](http://www.doctrine-project.org/jira/browse/DDC-162)
Author
Owner

@doctrinebot commented on GitHub (Nov 2, 2009):

Comment created by @beberlei:

This is an obvious fix, but it leads to the problem that the $params are not logged.

I ask myself if the SqlLogger shouldn't be passed to the Connection Driver also to solve this problem.

@doctrinebot commented on GitHub (Nov 2, 2009): Comment created by @beberlei: This is an obvious fix, but it leads to the problem that the $params are not logged. I ask myself if the SqlLogger shouldn't be passed to the Connection Driver also to solve this problem.
Author
Owner

@doctrinebot commented on GitHub (Nov 20, 2009):

Comment created by romanb:

Not only would the params not be logged but in the case of a prepared statement that is executed several times you would miss queries.

So this needs to be logged on the caller side where the statement is prepared and executed (one or more times).

@doctrinebot commented on GitHub (Nov 20, 2009): Comment created by romanb: Not only would the params not be logged but in the case of a prepared statement that is executed several times you would miss queries. So this needs to be logged on the caller side where the statement is prepared and executed (one or more times).
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2009):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 2, 2009): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#115