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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:45:54+00:00 2026-05-30T07:45:54+00:00

I have a doctrine query that returns blog posts and their comments: SELECT b,

  • 0

I have a doctrine query that returns blog posts and their comments:

SELECT b, c FROM BlogPost b LEFT JOIN b.comments c

I would like to limit the results to 10 blog posts. According to the DQL documentation, setMaxResults() doesn’t work correctly on queries that fetch-join a collection (comments in this case):

If your query contains a fetch-joined
collection specifying the result limit
methods are not working as you would
expect. Set Max Results restricts the
number of database result rows,
however in the case of fetch-joined
collections one root entity might
appear in many rows, effectively
hydrating less than the specified
number of results.

How would I properly limit a doctrine query that contains a fetch-joined collection (in this case, limit the results to 10 blog posts)?

  • 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-30T07:45:55+00:00Added an answer on May 30, 2026 at 7:45 am

    Paginate was merged with doctrine 2.2 And the new symfony2 release 2.0.10 is compatible with.

    Now use it like that

    //use Doctrine paginator
    use Doctrine\ORM\Tools\Pagination\Paginator;
    

    Write your query then call results like that.

    $query->setMaxResults($limit);
    $query->setFirstResult($offset);
    $results = new Paginator($query, $fetchJoin = true);
    

    Hope this will help you.

    Note: If you are using SF2 2.0.10, you should update the deps and deps.lock files and specify the 2.2 version for Doctrine bundles.

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

Sidebar

Related Questions

i have a query that returns ~50k rows, seems like doctrine put this whole
I have written a DQL query in Doctrine 2: $qb->select('r.position') ->from('\Entities\Races', 'r') ->where($qb->expr()->eq('r.entrantId', ':entrant_id'))
i have created this query that works OK: $q1 = Doctrine_Query::create() ->from('Usuario u') ->leftJoin('u.AmigoUsuario
I have a situation where I want to assemble a Doctrine select query based
I have an object that has an instance of Doctrine\ODM\MongoDB\Query\Builder . When I serialize
In my Symfony/Doctrine app, I have a query that orders by RANDOM(). I call
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized
I have two tables userdetails and blog question The schema is UserDetails: connection: doctrine
I have a doctrine update query to save my data: $customer = Doctrine_Query::create() ->update('Customer')
I have a UserForm class which has a select list populated from a related

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.