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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:13:42+00:00 2026-06-14T13:13:42+00:00

my problem is i want to do a Database find (Selection) witz a division

  • 0

my problem is i want to do a Database find (Selection) witz a division in sort. ^^

That looks in my Code like:

$return = $db->selectCollection( $category )->find(array("time" > $time_lastweek))->sort(array("rating/count_raitings" => 1,"count_raitings" => 1))->limit(10);

I have done this before in SQL (PDO) like this:

$last_week = $dbh->prepare('SELECT * FROM '.$category.' WHERE time > :zeit ORDER BY rating/count_raitings ASC, count_raitings ASC LIMIT 10');
        $last_week->execute(array(':zeit' => $time_lastweek));
        $return = $last_week->fetchAll(PDO::FETCH_CLASS);

Please can anyone help me. The MongoDB thing wont work for me.

  • 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-14T13:13:44+00:00Added an answer on June 14, 2026 at 1:13 pm

    Here’s how you could use the aggregation framework to do it in the shell (should be straightforward to translate to PHP):

    db.category.aggregate([
        // Filter the docs to those where time > time_lastweek
        { $match: {time: {$gt: time_lastweek}}},
    
        // Identify what to include from each doc, adding a computed field for the division
        { $project: {
            time: 1,
            rating: 1,
            count_raitings: 1,
            div_val: {$divide: ['$rating', '$count_raitings']}
        } },
    
        // Sort the results
        { $sort: {div_val: 1, count_raitings: 1}},
    
        // Limit to the top 10
        { $limit: 10 }
    ])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with a character encoding problem that I want to sort once
I have a problem. I want to use a LINQ query against this database:
Problem: I want disparate sections of my code to be able to access a
Problem I want to create an application that can be extended somehow by programmers.
I want to find the text in textbox in my database. I wrote the
Simple problem. I have an SQL Server database (MyData.mdf) and I want to convert
I have a database table containing two costs. I want to find the distinct
Problem I want to save the attributes of a model that have changed when
Problem I want to use the interactive debugger with IntelliJ. Unfortunately, I can't convince
Problem: I want to add headers in the middle of a gridview databind. I

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.