Skip to content

Commit

Permalink
fixed bugs in mint usercollection
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianGray committed Jan 30, 2012
1 parent 290d54a commit 238f6bb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core/Database/Collections/MongoDB/UserCollection.class.php
Expand Up @@ -91,5 +91,34 @@ public function ChangeScore(\Models\User $user)
}
return true;
}

public function ListBy(\Models\Search $search)
{
$fields = array();
$data = null;
$data = $this->Collection->find(array(), $fields);

if($search->SortField !== null)
$data = $data->sort(array($search->SortField => $search->SortDirection));

if($search->Limit != 0)
$data = $data->limit($search->Limit)->skip($search->Skip);

$result = array('Count'=>0, 'Items'=>array());

if($data)
{
$result['Count'] = $data->count();
foreach($data as $item)
{
$anItem = new \Models\Item();
self::fill($anItem, $item);
$result['Users'][] = $anItem;
}
}

return $result;
}

}
?>

0 comments on commit 238f6bb

Please sign in to comment.