Bug by inserting data #5827

Closed
opened 2026-01-22 15:18:58 +01:00 by admin · 1 comment
Owner

Originally created by @infastra on GitHub (Dec 31, 2017).

Originally assigned to: @Ocramius on GitHub.

I try to create a new database entry by using the class EntityManager with the method flush especially for one Entity. After call the method flush, I get the error SQLSTATE[HY093]: Invalid parameter number: no parameters were bound.

Here is my source code:

class MyEntityRepository extends Doctrine\ORM\EntityRepository {
public function save($entityObject) {
    $this->persist($entryObject);
    $this->getEntityManager()->flush($this->_class->rootEntityName);
}
}

When I only want to update an entity, it works.

After debugging I found out that the class Doctrine\ORM\UnitOfWork didn't have the entity in its entityChangeSet array in line 530.

I'm using version 2.5.14 of Doctrine.

When I call the flush method without any parameter it works. So did I use the method in a wrong way? What could I do when I want to insert data in one entity?

Originally created by @infastra on GitHub (Dec 31, 2017). Originally assigned to: @Ocramius on GitHub. I try to create a new database entry by using the class EntityManager with the method flush especially for one Entity. After call the method flush, I get the error SQLSTATE[HY093]: Invalid parameter number: no parameters were bound. Here is my source code: ```php class MyEntityRepository extends Doctrine\ORM\EntityRepository { public function save($entityObject) { $this->persist($entryObject); $this->getEntityManager()->flush($this->_class->rootEntityName); } } ``` When I only want to update an entity, it works. After debugging I found out that the class Doctrine\ORM\UnitOfWork didn't have the entity in its entityChangeSet array in line 530. I'm using version 2.5.14 of Doctrine. When I call the flush method without any parameter it works. So did I use the method in a wrong way? What could I do when I want to insert data in one entity?
admin added the BugInvalid labels 2026-01-22 15:18:58 +01:00
admin closed this issue 2026-01-22 15:18:58 +01:00
Author
Owner

@Ocramius commented on GitHub (Jan 1, 2018):

EntityManager#flush() expects a object|object[]|null as parameter.

Besides that, flushing single entities is deprecated and already removed in develop, which is going to be ORM 3.0. I strongly endorse not using EntityManager#flush($entity), but only EntityManager#flush().

@Ocramius commented on GitHub (Jan 1, 2018): [`EntityManager#flush()` expects a `object|object[]|null` as parameter](https://github.com/doctrine/doctrine2/blob/374e7ace49d864dad8cddbc55346447c8a6a2083/lib/Doctrine/ORM/EntityManager.php#L346). Besides that, flushing single entities is deprecated and already removed in `develop`, which is going to be ORM 3.0. I strongly endorse not using `EntityManager#flush($entity)`, but only `EntityManager#flush()`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5827