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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:14:36+00:00 2026-06-08T15:14:36+00:00

I just started exploring Symfony2 and I am amazed how many great features it

  • 0

I just started exploring Symfony2 and I am amazed how many great features it has. I started doing the blog tutorial at:
http://tutorial.symblog.co.uk/
but using version 2.1 instead of 2.0

My problem is that i have the following entity for Blog:

/**
 * @ORM\OneToMany(targetEntity="Comment", mappedBy="blog")
 */
protected $comments;

and the following in the Comment entity:

/**
 * @var string $blog
 *
 * @ORM\ManyToOne(targetEntity="Blog", inversedBy="comments")
 * @ORM\JoinColumn(name="blog_id", referencedColumnName="id")
 */
private $blog; 

I created the function to get the latest blogs and join the comments so i dont have to lazy load comments for each blog and avoid multiple calls to the comments table like so:

$qb = $this->createQueryBuilder('b')
            ->select('b')
            ->leftJoin('b.comments', 'c')
            ->addOrderBy('b.created', 'DESC'); 

but when i run in the twig template the result from that query as: blog.comments I got the first query to retrieve the blogs correct with the join in it but then instead of using the joined value for comments i get a call to the comments table for each blog entry? How do I bypass that functionality for that certain case but keep the relationship so i can get all comments for a blog from the view blog page?

  • 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-08T15:14:38+00:00Added an answer on June 8, 2026 at 3:14 pm

    You also need to add the comment objects to the select results:

    ->select('b', 'c')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started exploring Cocoa so pretty much a total noob. I've written a very
I just started exploring Java Servlets and JSP and am a little confused about
I have just started exploring TWILL . Twill is an amazing scripting language for
I just started exploring Scala in my free time. I have to say that
I have just started exploring SpringMVC and logback. This is my controller, (the only
Just started using Blueprint CSS and now playing with the grids but have a
I have just started this week in exploring Android Open GL ES and related
Just started tinkering with Dart and I decided to write a simple Http Server
I am a newbie just started exploring Grails so that I can recommend this
I have just started exploring Backbone.js. Upon submission of a form I would like

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.