DDC-2918: get statements from ORM #3632

Open
opened 2026-01-22 14:24:18 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 15, 2014).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user flip101:

When doing persist() and then flush() the statements are not accessible anymore after the operation is done.

The EntityManager uses an EntityPersister. When looking at the BasicEntityPersister->executeInserts() a new statement is created but it's not saved as part of another object.
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php#L260

Benefit:
When having access to the statements afterwards, all the following methods would be available:
http://www.php.net/manual/en/class.pdostatement.php

Most interesting are rowCount and error related methods.

Originally created by @doctrinebot on GitHub (Jan 15, 2014). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user flip101: When doing `persist()` and then `flush()` the statements are not accessible anymore after the operation is done. The EntityManager uses an EntityPersister. When looking at the BasicEntityPersister->executeInserts() a new statement is created but it's not saved as part of another object. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php#L260 Benefit: When having access to the statements afterwards, all the following methods would be available: http://www.php.net/manual/en/class.pdostatement.php Most interesting are rowCount and error related methods.
admin added the New Feature label 2026-01-22 14:24:18 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2014):

Comment created by @deeky666:

[~flip101] AFAIK you can use an SQL Logger for this which has to be set in the connection. The ORM testsuite makes use of this, too. See this example: https://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php#L155

@doctrinebot commented on GitHub (Jan 15, 2014): Comment created by @deeky666: [~flip101] AFAIK you can use an SQL Logger for this which has to be set in the connection. The ORM testsuite makes use of this, too. See this example: https://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php#L155
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2014):

Comment created by flip101:

Yes sure, but using a logger will be a strange way to pipe it back into business logic.

For example it's possible to do remove() on a proxy so you don't know if the row was present or not.

or another situation ..

when dealing with concurrency .. somebody else might have deleted the row already ..

@doctrinebot commented on GitHub (Jan 15, 2014): Comment created by flip101: Yes sure, but using a logger will be a strange way to pipe it back into business logic. For example it's possible to do remove() on a proxy so you don't know if the row was present or not. or another situation .. when dealing with concurrency .. somebody else might have deleted the row already ..
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3632