[PR #1000] [CLOSED] [DDC-3068] EntityManager::find accept array of object as id #9017

Open
opened 2026-01-22 16:02:48 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/1000
Author: @giosh94mhz
Created: 4/4/2014
Status: Closed

Base: masterHead: DDC-3068


📝 Commits (1)

  • 5e50d7e EntityManager::find accept array of object as id

📊 Changes

4 files changed (+78 additions, -8 deletions)

View changed files

📝 lib/Doctrine/ORM/EntityManager.php (+10 -8)
📝 tests/Doctrine/Tests/Models/Taxi/Car.php (+5 -0)
📝 tests/Doctrine/Tests/Models/Taxi/Driver.php (+5 -0)
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php (+58 -0)

📄 Description

Pull Request for ticket http://www.doctrine-project.org/jira/browse/DDC-3068
Here follow the ticket description for you convenience.

According to the documentation, EntityManager::find should return one entity given it's primary key. When a primary key of an entity is composed of multiple associations, one (me :)) would expect that the following works, but it doesn't:

$entity = $_em->find('My\EntityClass', array(
    'assoc1' => $instance1,
    'assoc2' => $instance2
));
PHP Fatal error:  Object of class My\EntityClass could not be converted to string

The only working way I've found is the following:

$entity = $_em->find('My\EntityClass', array(
    'assoc1' => $instance1->getId(),
    'assoc2' => $instance2->getId()
));

I think that this second scenario is not correct, since expose implementation details.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/1000 **Author:** [@giosh94mhz](https://github.com/giosh94mhz) **Created:** 4/4/2014 **Status:** ❌ Closed **Base:** `master` ← **Head:** `DDC-3068` --- ### 📝 Commits (1) - [`5e50d7e`](https://github.com/doctrine/orm/commit/5e50d7eb7fe163a05f2e8fc7eb8aa056131e981c) EntityManager::find accept array of object as id ### 📊 Changes **4 files changed** (+78 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/EntityManager.php` (+10 -8) 📝 `tests/Doctrine/Tests/Models/Taxi/Car.php` (+5 -0) 📝 `tests/Doctrine/Tests/Models/Taxi/Driver.php` (+5 -0) ➕ `tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php` (+58 -0) </details> ### 📄 Description Pull Request for ticket http://www.doctrine-project.org/jira/browse/DDC-3068 Here follow the ticket description for you convenience. According to the documentation, `EntityManager::find` should return one entity given it's primary key. When a primary key of an entity is composed of multiple associations, one (me :)) would expect that the following works, but it doesn't: ``` php $entity = $_em->find('My\EntityClass', array( 'assoc1' => $instance1, 'assoc2' => $instance2 )); PHP Fatal error: Object of class My\EntityClass could not be converted to string ``` The only working way I've found is the following: ``` php $entity = $_em->find('My\EntityClass', array( 'assoc1' => $instance1->getId(), 'assoc2' => $instance2->getId() )); ``` I think that this second scenario is not correct, since expose implementation details. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:02:48 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9017