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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:03:54+00:00 2026-06-05T03:03:54+00:00

I am creating an application that has an Entity that has multiple many-to-many relationships

  • 0

I am creating an application that has an Entity that has multiple many-to-many relationships with other objects. Let me layout the Entities:

  • Entry = the main object
  • Region = has many-to-many with Entry via “_entry_region” reference table
  • Type = has many-to-many with Entry via “_entry_type” reference table
  • Tag = has many-to-many with Entry via “_entry_tag” reference table

Now in the frontend the user can setup some filters for the entries that need to be loaded. In human language the query needs to be like this.

Get the entries WHERE  region is (1 or 2 or 3) AND type is ( 3 or 4 or 5 ) AND tag is ( 4 OR 6 or 1)

i currently strugle with this piece of code:

$query = $this->em->createQuery('SELECT m.id FROM Entity\Entry e WHERE :region_id MEMBER OF e.regions);
$query->setParameter('region_id',  1);      
$ids = $query->getResult();

This gives me the ID’s of the entry’s of the corresponding region. but it is not possible to add an array of the region id’s in the setParameter(). I also can’t find in the docs how to do this on multiple related entities like my human based query:

Get the entries WHERE  region is (1 or 2 or 3) AND type is ( 3 or 4 or 5 ) AND tag is ( 
  • 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-05T03:03:55+00:00Added an answer on June 5, 2026 at 3:03 am

    You might also consider taking a look at the D2 query builder. Bit more verbose but it’s much easier to build more complicated queries once you get the syntax down.

    Something like:

        $qb = $this->em->createQueryBuilder();
    
        $qb->addSelect('entry');
        $qb->addSelect('region');
        $qb->addSelect('type');
        $qb->addSelect('tag');
    
        $qb->from('MyBundle:Entry',   'entry');
        $qb->leftJoin('entry.regions','region');
        $qb->leftJoin('entry.types',  'type');
        $qb->leftJoin('entry.tags',   'tag');
    
    
        $qb->andWhere($qb->expr()->in('region.id',$regions));
        $qb->andWhere($qb->expr()->in('type.id',  $types));
        $qb->andWhere($qb->expr()->in('tag.id',   $tags));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a business application that has a variable width sidebar and content
I am creating an ASP.NET MVC application that has postcode lookup functionality. I capture
Here's something that has been bugging me... I am currently creating an application for
Let's say your creating an application that needs to send you an email monthly.
I am currently creating an application that has a user, the user can follow
I'm creating an application that has to handle the construction cases of a small
I want to start creating an application that has a menu on the left(some
I'm creating an application that has a Gallery , and this Gallery has a
I creating a C# application that has to create a word document. I'm using
I am creating an application that has several servers running at the same time

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.