Showing posts with label order clause. Show all posts
Showing posts with label order clause. Show all posts

Sunday, February 13, 2011

order by clause in mongodb

$dd=array('flag'=>0,'status'=>1);
$s=array( 'id' => -1);
$cursor = $collection->find($dd)->sort($s)->limit(10)->skip(0);

foreach ($cursor as $obj)
{
$username=$obj["username"];

}


  id => -1 means sorting  (desc)  order in mongodb


in sql --->       order by id desc limit 0,10;