Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8968817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:30:23+00:00 2026-06-15T17:30:23+00:00

I have an entity that has multiple keys, how would I go about finding

  • 0

I have an entity that has multiple keys, how would I go about finding the proper object based on multiple ids?

$product = $em->getRepository('AcmeStoreBundle:Product')->find($id);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:30:24+00:00Added an answer on June 15, 2026 at 5:30 pm

    It’s a little confusing what you’re asking here. It sounds as though you have an entity with a compound key (primary key relates to multiple columns) and want to find it based on it’s primary key values, yes?

    If so, the find method will require an array containing values for each of the fields that make up the key:

    $product = $em->getRepository('AcmeStoreBundle:Product')->find(array(
        'key1' => 'value1', 
        'key2' => 'value2'
    ));
    

    Alternatively, you could use findOneBy method. This would be useful for when the combination of the provided fields are not unique as you’re able to provide a second argument to define the ordering.

    $product = $em->getRepository('AcmeStoreBundle:Product')->findOneBy(array(
        'key1' => 'value1', 
        'key2' => 'value2'
    ), array('updated_at' => 'DESC'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Video entity that has multiple Genres, public class Video { public
Using EF Code First I have an model object that has multiple properties that
I have an entity that has a few relations. I need to clone this
I have an entity that has a collection in it. The collection is a
Imagine you have an entity that has some relations with other entities and you
Let's say we have an entity that has attributes att1 and att2, where att1
I have an entity Company that has many Orders. I mapped these as following
A have a JPA entity that has timestamp field and is distinguished by a
I have an entity class that has 10 fields. I am using MS Validation
I have an entity (Org) in my Entity Framework that has a foreign key

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.