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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:07:44+00:00 2026-05-23T01:07:44+00:00

I am storing data for lap times in a database, the data consists of

  • 0

I am storing data for lap times in a database, the data consists of a distance, time, average speed and max speed.

I am trying to display a leaderboard which shows the top ten people in whatever query you set (who has gone thr furthest in total, best average time etc). However, below the top ten I want to show the user who is logged ins position in the leaderboard. To do this I am trying to run the same query ordering my results and adding a ROW NUMBER to get the position.

I am using symfony 1.4 with the Doctrine ORM and I can’t for the life of me figure out how to get row numbers in a query. I know you can do it in SQL like so:

SELECT full_name, ROW_NUMBER() OVER(ORDER BY distance) AS row_number

Yet I can’t get it working in Doctrine Symfony.

Does anyone have any ideas on a way I can do this? (or even another way of going about it)

Thanks in advance.

  • 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-23T01:07:44+00:00Added an answer on May 23, 2026 at 1:07 am

    Ok heres my solution:

    I kind of found an answer to this after some more experimenting and collaborating.

    What I did was get rid of the select and just return the ordered list of results;

    $results = self::getInstance()->createQuery('r')
        ->orderBy('r.distance')
        ->execute();
    

    Then I hydrated this result into an array and used array_search() to find the key of the result in the array (luckily I am returning user data here, and I know the user I am looking for in the array)

    $index = array_search($user->toArray(), $results->toArray());
    

    I can then return the $index + 1 to give me the users position in the leaderboard.

    There is probably a better way to do this database side, but I couldn’t for the life of me find out how.

    If anyone has a better solution then please share.

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

Sidebar

Related Questions

In which cases storing data as XML is preferable to RDBMS and why? Can
I often find myself storing data in a mysql database, and then wanting to
I am using Microsoft Access database for storing data. In that, I stored date
We have a web app, which is written in Java, and storing data into
I am trying to re-load data into the Store which is further used by
Hi i Have Used Database file for storing Data in my Application. Now I
I am facing an issue in storing data in persistence store,i am trying to
We know xml is used for storing data,which can be ported across platforms(underlying principle
does anybody know of a library for storing data securely in an 8k-EEPROM, which
I’m storing data that my app uses in isolated storage which is working fine.

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.