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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:29:24+00:00 2026-05-31T21:29:24+00:00

So I came to a point where I needed to create a custom query

  • 0

So I came to a point where I needed to create a custom query in my Entity Repository to do a sub-select.

The query itself seems sound and does indeed find the result I am after (I checked by running the query in Navicat) however, when trying to view the results (using Twig templates) I am getting the following error:

Item “id” for “Array” does not exist in DEMODemoBundle:Staff/Company:company.html.twig at line 42

Line 42 in that template is:

<td><a href="{{ path('staff_company_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>

Previously, I was using a basic “findAll” query in my controller, and the Twig template worked fine (it uses a for loop to go through the results and print out a table)

So, I was under the assumption that if my custom query fetched a list of results, with all the same columns (just 1 added extra in the sub-select, not the ID mentioned though) then everything should be fine!

But clearly not. It seems as though there is another Array level for some reason and I am unsure as to why?

Here is my custom query in the repo (it does a sub select to create a parent_name column):

public function getCompanyWithParent()
{
    $dql = 'SELECT c, (SELECT p.name FROM DEMO\DemoBundle\Entity\User\Company p WHERE p.id = c.parent) as parent_name FROM DEMO\DemoBundle\Entity\User\Company c';

    $query = $this->getEntityManager()->createQuery($dql);

    return $query->getArrayResult();
}

I have tried both:

return $query->getArrayResult();

and

return $query->getResult();

But to no avail.

Any ideas folks?

  • 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-31T21:29:26+00:00Added an answer on May 31, 2026 at 9:29 pm

    Sorted it. Seems I had to specify the columns I wanted to pull through e.g. SELECT c.id, c.name …, and sadly couldn’t just use SELECT c, … FROM …

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

Sidebar

Related Questions

I'm exploring annotations and came to a point where some annotations seems to have
I'm working with MVC3 and Entity Framework but i came to a point where
I'm developing a little project plan and I came to a point when I
At some point when i did a build of my app, it came up
I'm using CAL framework in my application and I came to a point where
While searching for difference between HTML4 and HTML5 I came across the point that
I came to a point where I realized that I need an intelligent solution
I'm working on a project and I came to a point where the following
While commenting on an answer in this other SO post , the point came
I was going through this link , where I came across a point Avoid

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.