Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit()method is not work. #18

Open
xiaobopang opened this issue Aug 9, 2017 · 2 comments
Open

limit()method is not work. #18

xiaobopang opened this issue Aug 9, 2017 · 2 comments

Comments

@xiaobopang
Copy link

xiaobopang commented Aug 9, 2017

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 xiaobopang changed the title limit 分页好像有问题。 limit()method is not work. Aug 9, 2017
@callmejea
Copy link

callmejea commented Nov 20, 2017

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
Copy link

now I do like this:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants