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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:00:48+00:00 2026-05-30T14:00:48+00:00

The symfony framework features an app/console file that can be executed via php to

  • 0

The symfony framework features an app/console file that can be executed via php to perform some maintenance tasks. It allows users to run DQL queries as well:

# php app/console doctrine:query:dql --hydrate=array \
    'SELECT u.id, u.nameFirst, u.nameLast  FROM DatabaseBundle:User u'  
array
  0 => 
    array
      'id' => string '1' (length=1)
      'nameFirst' => string 'jaroslav' (length=8)
      'nameLast' => string 'rakhmatoullin' (length=13)
  1 => 
    array
      'id' => string '2' (length=1)
      'nameFirst' => string 'Båb Kåre' (length=10)
      'nameLast' => string 'Ytrefoss' (length=8)

Observe that I selected three specific columns. The problem I’m having is that a similar query gives me an error when two tables are joined.

# php app/console doctrine:query:dql  --hydrate=array \
    'SELECT u.id , r FROM DatabaseBundle:User u JOIN u.roles r'

  [Doctrine\ORM\Query\QueryException]                   
  [Semantical Error] line 0, col -1 near 'SELECT u.id ,': 
     Error: Cannot select entity through identification variables 
     without choosing at least one root entity alias.  

The following returns the whole user joined with his roles:

# php app/console doctrine:query:dql  --hydrate=array \
     'SELECT u, r FROM DatabaseBundle:User u JOIN u.roles r'

Obviously, I’m missing something.

Any ideas? I would appreciate links to appropriate docs too (on this specific matter).

  • 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-30T14:00:49+00:00Added an answer on May 30, 2026 at 2:00 pm

    From the documentation on "Partial Object Syntax":

    By default when you run a DQL query in Doctrine and select only a subset of the fields for a given entity, you do not receive objects back. Instead, you receive only arrays as a flat rectangular result set, similar to how you would if you were just using SQL directly and joining some data.

    If you want to select partial objects you can use the partial DQL keyword.

    php console doctrine:query:dql --hydrate array \
      'SELECT partial s.{name ,id}, partial c.{name, id } 
       FROM DatabaseBundle:ProductCategories c 
       JOIN c.suppliers s ORDER BY s.name, c.name'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a site using symfony php framework. I have a link in my
I just started to use the PHP symfony framework. Currently I'm trying to create
I'm using PHP with the Symfony framework (with Doctrine as my ORM) to build
I'm building a web application with the Symfony Framework. The purpose of this app
I'm new to version 2 of the Symfony framework. I made some projects with
I am working in PHP(with Symfony Framework) and i want to create a search
I'm using PHP with the Symfony framework for my web projects. The framework allows
In my PHP application ( constructed using symfony framework and Propel ORM), when I
We are develping an application using PHP and Symfony framework. Ideally the system would
In Java, I use log4J that is a logging framework. In Log4j you can

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.