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.
Here’s how you could use the aggregation framework to do it in the shell (should be straightforward to translate to PHP):