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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:51:35+00:00 2026-05-31T03:51:35+00:00

I’m using Symfony 2 with doctrine. I’ve set up a custom repository with a

  • 0

I’m using Symfony 2 with doctrine. I’ve set up a custom repository with a custom find function. As it joins to a subquery I’m pretty sure from what I’ve read that I’ll need to use the ResultSetMappingBuilder to get the results back from the query. But I keep getting the following error:

The column 'id' conflicts with another column in the mapper. 

My code is:

    $sql ="SELECT c.id as cid, c.country, c.rank, c.continent, q.*
        FROM country c
        INNER JOIN (
            SELECT d.* , MAX( d.rating ) AS maxrating
            FROM ducks d
            GROUP BY d.country_id
        )q ON ( q.country_id = c.id )";

    $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->getEntityManager());
    $rsm->addRootEntityFromClassMetadata('Wfuk\DuckBundle\Entity\Country', 'c', array('id' => 'cid'));
    $rsm->addJoinedEntityFromClassMetadata('Wfuk\DuckBundle\Entity\Ducks', 'ducks', 'c', 'country_id');

    $query = $this->getEntityManager()->createNativeQuery($sql, $rsm);
    return $query->getResult();

The SQL query runs on it’s own without any problems and returns the results I’d expect.

UPDATE, I’ve fixed the id issue by remapping the id field on the addRootEntityFromClassMetadata, but I’ve still got a remaining problem with the revised joinedEntity:

    $rsm->addJoinedEntityFromClassMetadata('Wfuk\DuckBundle\Entity\Ducks', 'ducks', 'c', 'country_id');

I get the following error:

Notice: Undefined index: country_id in E:\Documents\wfuk\Work\duck travels\wamp\vendor\doctrine\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php line 85 

I’m pretty sure this is down to the last value in the call, country_id, but I’m not 100% sure what this is. The explanation here: http://readthedocs.org/docs/doctrine-orm/en/latest/reference/native-sql.html isn’t too clear and I don’t fully understand the description from the class docblock.

The error it gives is:

The column 'id' conflicts with another column in the mapper. 

Yet I have renamed the id field for one of the results so the result set only has one column called ‘id’.

The stacktrace on the error shows it’s being thrown here:

at ResultSetMappingBuilder ->addAllClassFields ('Wfuk\DuckBundle\Entity\Ducks', 'q', array())
in E:\Documents\wfuk\Work\duck travels\wamp\vendor\doctrine\lib\Doctrine\ORM\Query\ResultSetMappingBuilder.php at line 71


I suspect it’s something obvious but there’s not much in the way of documentation on this function that I could find anywhere…

SOLVED:

I can’t add this as an answer for another 5 hours, so to avoid anyone wasting time answering this the answer is:

For anyone who has the same problem the problem was with the 4th parameter sent on this line:

$rsm->addJoinedEntityFromClassMetadata('Wfuk\DuckBundle\Entity\Ducks', 'ducks', 'c', 'ducks');

Which should have held the field within the Country class that I was using to store the arrayCollection of ducks within it.

  • 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-31T03:51:36+00:00Added an answer on May 31, 2026 at 3:51 am

    Just closing the question as it’s solved:

    For anyone who has the same problem the problem was with the 4th parameter sent on this line:

    $rsm->addJoinedEntityFromClassMetadata('Wfuk\DuckBundle\Entity\Ducks', 'ducks', 'c', 'ducks');
    

    Which should have held the field within the Country class that I was using to store the arrayCollection of ducks within it.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.