Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array
- (
- [_id] => MongoId Object
- (
- [$id] => 4e465de048177e8105000003
- )
- [id_usuario] => MongoId Object
- (
- [$id] => 4e43b20648177e5305000000
- )
- [mensaje] => lero lero si?
- [created_at] => MongoDate Object
- (
- [sec] => 1313234400
- [usec] => 160000
- )
- [comentarios] => Array
- (
- [0] => Array
- (
- [comentario] => hola mundo
- [usuario] => [_id] => MongoId Object
- (
- [$id] => 4e465de048177e8105000003
- )
- [created_at] => MongoDate Object
- (
- [sec] => 1313234400
- [usec] => 160000
- )
- )
- [1] => Array
- (
- [comentario] => hola mundo
- [usuario] => [_id] => MongoId Object
- (
- [$id] => 4e465de048177e8105000003
- )
- [created_at] => MongoDate Object
- (
- [sec] => 1313234400
- [usec] => 160000
- )
- )
- )
- )
- $db->usuarios->find()->sort(array('created_at' => -1))->limit(10)->skip(0);
- $db->usuarios->find()->sort(array('created_at' => -1))->limit(10)->skip(0);
- $user = $db->usuarios->find()->sort(array('commentarios.created_at' => -1)->limit(3);
- $comments = array_merge($user[0]['commentarios'], $user[1]['commentarios'], $user[2]['commentarios']
- $ordered = uasort($comments, 'sorter')
- function sorter($a, $b) {
- return $a['created_date'] < $b['created_date'];
- }
Add Comment
Please, Sign In to add comment