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

  • Home
  • SEARCH
  • 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 6145589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:48:56+00:00 2026-05-23T18:48:56+00:00

$q_auctions = Doctrine_Query::create() ->select(‘COUNT(t.id) AS num_items’) ->from(‘Auctions t’) ->where(‘t.ends_at > NOW()’); $q_auctions_upcoming = Doctrine_Query::create()

  • 0
    $q_auctions = Doctrine_Query::create()
       ->select('COUNT(t.id) AS num_items')
       ->from('Auctions t')
       ->where('t.ends_at > NOW()');

    $q_auctions_upcoming = Doctrine_Query::create()
       ->select('COUNT(t.id) AS num_upcoming')
       ->from('Auctions t')
       ->where('t.starts_at > NOW()');

    $q_auctions_closed = Doctrine_Query::create()
       ->select('COUNT(t.id) AS num_closed')
       ->from('Auctions t')
       ->where('t.ends_at < NOW()');

I have these 3 very similar auctions in Doctrine, but I’m not sure wether I can shorten it somehow. I don’t like so much repeating so maybe if someone could give me a tip.

  • 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-23T18:48:57+00:00Added an answer on May 23, 2026 at 6:48 pm

    First of all, I wouldn’t worry about having the three queries too much unless you’re really trying to cut down the total number of queries for this page. Indexes on starts_at and ends_at might help speed things up but depends on the number of records in those tables.

    The only thing that comes to mind right now would be to do a single query, return the start and end dates, and then parse those inside a PHP foreach loop into the three groups you need. This would drop the queries from 3 to 1 but add some PHP overhead. If you’ve got hundreds or thousands of auctions there, this might not be a good idea.

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

Sidebar

Related Questions

OdbcDataReader q = dbc.Query(SELECT * FROM `posts` WHERE `id`= + id.ToString()); if (q.RecordsAffected <
Q: Does a colon : in an array key have any special significance? From
Q: I'm a beginner to the XML.I have some data comes from my database,
Q: If I have a composite key combined from 4 fields for example, can
Q: Please , i want to ask ,how to perform a query(select statement) using
Q: How do I make MySQL only SELECT all users that have played =>
Q: How does Web Applications differ from SmartPhone Applications (Iphone, Windows Mobile, Android/Nexus Application)
Q: How can I create optGroups within a multiselect given the following: Model (pseudo):
Q: I face the following problem only when i tried my web site from
Q 1. To my understanding FormsAuthenticationModule is subscribed to AuthenticateRequest event, and thus only

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.