Phalcon-MongoDB-ODM icon indicating copy to clipboard operation
Phalcon-MongoDB-ODM copied to clipboard

limit()method is not work.

Open xiaobopang opened this issue 6 years ago • 2 comments

hello, when i use limit() method query ,i get return results is not what i want . public static function queryNearby($longitude, $latitude, $maxdistance, $pageSize = 10, $pageNumber = 0) { $param = array( 'loc' => array( '$nearSphere' => array( '$geometry' => array( 'type' => 'Point', 'coordinates' => array(doubleval($longitude), doubleval($latitude)), ), '$maxDistance' => $maxdistance //$maxdistance*1000 ) ) ); $columns = ['id','store_name','address','commercial_activities','status','loc','district_no']; $cursor = Stores::query()->where($param)->columns($columns)->limit((int)$pageSize,(int)($pageNumber))->get(); $result = $cursor->toArray(); return $result; }

xiaobopang avatar Aug 09 '17 14:08 xiaobopang

what you did at last? in fact, that's offset caution the error, but I don't know what to do , I'm new in mongodb; when the offset is smaller than 10 , that's good; here i have the same error, when set limit(10,$offset); $query is request from url; it stoped and return an empty array, the code is :

ModelName::query()->orderBy("_id","desc")->limit(10, $offset)->get()

php version is : 7.1.6 mongodb : 3.4 Phalcon-mongodb-odm : 1.0.6

callmejea avatar Nov 20 '17 12:11 callmejea

now I do like this:

where("_id", ">", new \MongoDB\BSON\ObjectId("59fa847a9c565bd0ccf2a9a4"))

callmejea avatar Nov 20 '17 14:11 callmejea