MongoDB Class, fixed bug in GetCountSortedByField

This commit is contained in:
Andre Lorbach 2012-05-02 17:11:58 +02:00
parent a241de09e1
commit 38795d48cb

View File

@ -1191,14 +1191,11 @@ class LogStreamMongoDB extends LogStream {
{ {
// Sort Array // Sort Array
arsort($aResult,SORT_NUMERIC); arsort($aResult,SORT_NUMERIC);
// Check if we have to truncate the array // Check if we have to truncate the array
if ($nRecordLimit != 0 && count($aResult) > $nRecordLimit) if ($nRecordLimit != 0 && count($aResult) > $nRecordLimit)
{ {
// Create new stripped array // Slice all unecessary entries from array!
$aStripResult = array (); $aStripResult = array_slice($aResult, 0, $nRecordLimit);
for($iCount = 0; $iCount < $nRecordLimit; $iCount++)
$aStripResult[$iCount] = $aResult[$iCount];
// Overwrite stripped results // Overwrite stripped results
$aResult = $aStripResult; $aResult = $aStripResult;