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);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
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
findmethod will require an array containing values for each of the fields that make up the key:Alternatively, you could use
findOneBymethod. 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.