php - Sorting a collection in doctrine2 -


i've written following query (that may or may not efficient, i'm still newbie):

    $collection     = $this->dm->getconnection()->selectcollection('db_name', 'collection_name');     $query          = array('array_name' => new \mongoid(id));     $cursor         = $collection->find($query)->limit(9)->sort('r', 'desc'); 

i'm trying sort r value looks in document:

"r": 0.58325652219355106354 

but isn't sorting r-value. doing wrong?

pretty sure sort takes array argument. try

->sort(['r' => 'desc]); 

i looked up... http://apigen.juzna.cz/doc/doctrine/mongodb/source-class-doctrine.mongodb.cursor.html#564-585


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -