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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:48:15+00:00 2026-06-04T09:48:15+00:00

I have such a structure: single profile can attend do several studies and for

  • 0

I have such a structure: single profile can attend do several studies and for each study there is statute field which is foreign key to study_statute. In HTML in each row I need to show information for profile: profile.name, profile.study.field, profile.study.statute. I’ve done this using

$profileRepository->findAll()

but it generates to many queries and I want to optimize. At the moment there is query fetching profiles , for each profile ask for studies and for each study ask for statute name. So if there are 2 profiles and each profile attends to 2 studies I have

1 (list)
+1 (study list for profile #1)
+2 (study names for each of above studies)
+1 (study list for profile #2)
+2 (study names for each of above studies)
queries.

How to optimize this?

In plain PHP I’d do: fetch big table for all profiles joined with studies and study names and parse it to multidimensional arrays, f.e. $profile[1]['studies'][1]['name'].

  • 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-04T09:48:16+00:00Added an answer on June 4, 2026 at 9:48 am

    You can use dql fetch join:

    $profiles = $em->createQuery('select p, stu, sta from YourBundleName:Profile p join p.studies stu join stu.statute sta')
        ->getResult();
    

    The result would be the same as if you would use findAll except one thing. All related entities would have been fetched. If you access the “study” or “statute” Doctrine does not need to lazy load the association with another query.

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

Sidebar

Related Questions

I have a server application with such structure: There is one object, call him
I have a basic structure as such: <g:form> actionSubmit </g:form> <g:form> actionSubmit </g:form> <g:each
I have such structure in my jsp: <h:commandLink action=#{docbean.save}> <a4j:actionParam name=somename value=bill_all assignTo=#{billdoc.billType}/> <a4j:actionParam
I have such database structure (1 - one, 0 - many) Product 1->0 Orders
I have such a C++ structure: typedef struct _FILE_OP_BLOCK { unsigned short fid; //
I have to parse a 1Gb XML file with a structure such as below
Suppose I have code that maintains a parent/children structure. In such a structure I
Suppose I have a structure in C or C++, such as: struct ConfigurableElement {
We have an PHP/MySQL application where the users can create their own databases, which
I have a large tree-like data structure of objects which behave mostly identical but

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.