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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:28:07+00:00 2026-06-15T15:28:07+00:00

I want to order entities returned from a Doctrine query on a calculated scalar

  • 0

I want to order entities returned from a Doctrine query on a calculated scalar value. Something like this in simplified DQL:

SELECT a, SOMEFUNC(a.foo,a.bar) AS b 
FROM MyStuff:Thing a 
ORDER BY b

The ordering works, but I don’t actually want the scalar value b, it’s just for sorting; I only want Thing entities back.

However with this query each result returned would be an array with the root object I want at [0] and then the redundant scalar value at [1]. This makes perfect sense, but it’s not what I want and I don’t know how to ask Doctrine to ignore the value.

How is this kind of ordering supposed to be done with Doctrine? How do I perform this ordering without selecting?

  • 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-15T15:28:09+00:00Added an answer on June 15, 2026 at 3:28 pm

    Use the AS HIDDEN clause:

    SELECT a, SOMEFUNC(a.foo,a.bar) AS HIDDEN b 
    FROM MyStuff:Thing a 
    ORDER BY b
    

    Source : https://speakerdeck.com/asm89/what-is-new-in-doctrine?slide=19

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

Sidebar

Related Questions

I want to order values from database query by date but I want also
I have two entities that are something like that: public class Movie { public
I have data that looks like this: entities id name 1 Apple 2 Orange
I would like to order entities by ancestor, GQL reference only mentions properties in
I have a 3-leveled hierarchy of entities: Customer-Order-Line, which I would like to retrieve
I'm using Fluent NHibernate in order to auto map my entities. This is the
I using Query DSL generated entity EntitySerializer in order to query JPA entities using
I want the following function to validate a string if it looks like this:
Domain Model I am working on has root aggregate and child entities. Something like
I have a query as such (simplified): var q = from t in _entities.Table

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.