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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:52:36+00:00 2026-06-13T18:52:36+00:00

Currently i develop an rest-api-app with symfony2 and doctrine2. My API should has the

  • 0

Currently i develop an rest-api-app with symfony2 and doctrine2. My API should has the functionality to filter the results by an querystring.
For example, the following url:
http://example.com/api/users?orderBy=username%20DESC&limit=20

I can parse the querystring with parse_str($this->getRequest()->getQueryString(), $queryString); to an assoc array.
Is there any function that i can commit the array and doctrine selects the corresponding results? Something like $users = $this->getDoctrine()->getRepository('UserBundle:User')->findByQueryString($queryString);

  • 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-13T18:52:38+00:00Added an answer on June 13, 2026 at 6:52 pm

    As AdrienBrault said don’t use parse_str instead put this in your controller:

    $orderBy = $this->get('request')->query->get('orderBy');
    $limit = $this->get('request')->query->get('limit');
    $rep = $this->getDoctrine()->getRepository('UserBundle:User');
    $users = $rep->findLimitOrderBy($orderBy, $limit);
    

    And inside your user repository class:

    public function findLimitOrderBy($orderBy, $limit)
    {
    $query = $this->getEntityManager()
        ->createQuery('
        SELECT u FROM UserBundle:User u
        ORDER BY u.'.$orderBy
        )
        ->setMaxResults($limit);
    
        return $query->getResult();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently develop an application hosted at google app engine. However, gae has many
I currently develop an iOS app for a local business directory, and I use
I am currently develop iphone app. the type of the app is Tab Bar.
I currently develop a server application which has to receive serialized data from clients,
I am currently trying to develop an application which uses Skype API to call
I'm currently using the iOS 5 SDK trying to develop my app. I'm trying
I currently develop a task queue with a RESTful API. In order to handle
I'm trying to develop a simple WP7 app that queries a REST feed which
Is there any google calendar api for iphone sdk, currently I develop an iphone
I am currently planning to develop a web-app which will allow a 3rd party

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.