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 8057729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:07:38+00:00 2026-06-05T09:07:38+00:00

I am currently learning Symfony and Doctrine by reading the docs . I don’t

  • 0

I am currently learning Symfony and Doctrine by reading the docs.

I don’t understand the difference between find and findOneById. I tried to use them both in this simple example and it looks they do the same thing to me.

$product = $this->getDoctrine()
                ->getRepository('AcmeStoreBundle:ProductEntity')
                ->findOneById($id);

Are they really the same thing or there is some difference? And where I can find the detailed documentation for all these methods?

  • 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-05T09:07:40+00:00Added an answer on June 5, 2026 at 9:07 am

    In your case, they happen to do the same thing. Looking at this example, you’ll notice that find() looks for the field named after the primary key. findOneBy<Field>() will explicitly use the field in the name of the method, even if it’s not the primary key, and will return the first record. So, in the end, if the primary key is indeed named id, then both will do the same thing.

    // query by the primary key (usually "id")
    $product = $repository->find($id);
    
    // dynamic method names to find based on a column value
    $product = $repository->findOneById($id);
    $product = $repository->findOneByName('foo');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am currently learning how to use service and notifications in android and
I'm learning Symfony + Doctrine 1.2 by writing a web app. As the app
Currently learning Spring MVC with Spring 3, I'm trying to find the correct way
I'm currently learning C#, but I am stuck on something and I can't find
I am currently learning to use Springy which is a force directed graph layout
I´m currently learning WPF and the use of MultiTrigger and Conditions to set some
I'm currently learning ASP.NET MVC and using Nhibernate. I would like to use Cascading
I am currently learning how to use the symfony2 framework. Going through the cook
I am currently learning java, I understand the concepts except Graphics which as a
im currently learning python (in the very begining), so I still have some doubts

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.