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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:54:35+00:00 2026-05-21T11:54:35+00:00

I know conditional filters aren’t yet available for queries (as per 26.1.4. Applying Filter

  • 0

I know conditional filters aren’t yet available for queries (as per “26.1.4. Applying Filter Rules to any Query” in the Known Limitations section of the Doctrine2 manual) , so I wanted to ask the experts what their preferred solution to the following problem is:

My site has product objects that each have many reviews. The reviews have a status field. I don’t want to unnecessarily pull in reviews that haven’t been approved during the automatic association that Doctrine2 does so wonderfully.

My current solution/hack is to use single table inheritance (STI) with a discriminator for “status” and have an ApprovedProductReview extending the ProductReview class based on a status of “APPROVED”

I should add that I am currently simply calling

$em->find('Entities\Product', $pid);

to get my product, and Doctrine2 does all the associations automatically. Should I instead be instantiating a product by providing a DQL query?

What I’d really like is a way to override the magic that Doctrine2 provides based on the annotations, and simply be able to use DQL to lazily get the correct subset of reviews.

Suggestions?

  • 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-05-21T11:54:35+00:00Added an answer on May 21, 2026 at 11:54 am

    You can use the WITH statement in DQL:

    $dql = "SELECT p, r
            FROM Entities\Product p
            LEFT JOIN p.reviews r WITH r.status = :status
            WHERE p.id = :id"
    
    $q = $em->createQuery($dql);
    $q->setParameter('id', $id);
    $q->setParameter('status', $status);
    $product = $q->getSingleResult();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I know when writing a conditional statement in C such as
Does anyone know of a Sharepoint webpart that provides conditional formatting? For example, if
I would like to do conditional compilation in a program of mine. I know
Know of any good libraries for this? I did some searches and didn't come
I know that key-value pairs aren't good database design, aren't normalized etc however in
Is there any easy way to filter items in a SWT Table ? and
I'm constructing some Django filter queries dynamically, using this example : kwargs = {
I have IQuerable<MyEntity> and filters(conditions list), that i want to apply to my query.
I'd like to know if having to conditionals when using a JOIN keyword is
I know it is a condition of hard links that they cannot span filesystems.

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.