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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:20:01+00:00 2026-06-05T11:20:01+00:00

This is similar to this question posted previously: In Symfony2, should I use an

  • 0

This is similar to this question posted previously:
In Symfony2, should I use an Entity or a custom Repository

Lets say I have a car entity and a Wheels entity. A car has many wheels but a wheel has a single car.

In my controller I already have access to the car. I’m using the relation to get the wheels belonging to the car.

$car = $this->getCar();
$wheels= $car->getWheels();

The above works and gives me access to the wheels belonging to the current car. But instead of getting all wheels, I only need wheels where flat = 0.

Is there a better way than a repository to get the wheels belonging to the car entity where flat = 0?

I was thinking of creating a getter in the car entity (getNonFlatWheels) then filtering the wheels so that only the non flat wheels are returned.

Seems there would be a more standard solution.

  • 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-05T11:20:01+00:00Added an answer on June 5, 2026 at 11:20 am

    I do not know your entities structure, but in a similar situation I use this snippet of code. You can try to put it in CarRepository class.

    /**
     * Get all non flat wheels
     *
     * @return Result
     */
    public function getNonFlatWheels()
    {
        $em = $this->getEntityManager();
    
        $query = $em
                ->createQuery("
                    SELECT g
                    FROM Acme\DemoBundle\Entity\Car c
                    JOIN c.wheels w
                    WHERE w.flat = :flat
                ")
                ->setParameter('flat', 0);
    
        return $query->getResult();
    }
    

    I hope it will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have posted a question on here previously asking similar advise, but this project
I have posted similar question previously, but this time I am providing some code
I posted another question similar. This is my old code as some ppl say
I know that this question is very similar to the question posted here .
I have checked this similar question, but the suggestions did not solve my problem:
This is similar to this question, except the code is already written. I have
I know a similar question has been posted before but I think this is
I have a similar question posted, but did not quite get the answer I
I have gone through all the answers for the similar question posted earlier Replacing
Edit at bottom with solution I've seen a similar question to this posted before

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.