I'm trying to use options in MongoDB\Driver\Query:
$options = array();
...
if (isset($limit['page']))
{$options['skip']=($limit['page'] - 1) * $limit['hpp'];}//20
if (isset($limit['hpp']))
{$options['limit']=$limit['hpp'];//20
$options['batchSize']=$limit['hpp'];}//20
print('<br />--------$options :<br />');
print_r($options);
$query = new MongoDB\Driver\Query($search, $options);
print('<br />********$query :<br />');
echo '<pre>';
print_r($query);
echo '</pre>';
If $options seems ok:
--------$options :
Array ( [sort] => Array ( [_id] => 1 ) [skip] => 20 [limit] => 20 [batchSize] => 20 )
$query doesn't give me the good options:
********$query :
MongoDB\Driver\Query Object
(
[query] => stdClass Object
(
[$orderby] => stdClass Object
(
[_id] => 1
)
[$query] => stdClass Object
(
)
)
[selector] =>
[flags] => 0
[skip] => 20
[limit] => 0
[batch_size] => 0
[readConcern] =>
)
limit and batch_size are not equals to 20, why? and how to do, please?
Thanks in advance
filter=>Object, options=>Object, readConcern=>Object, see SaschaM78's answer. Yourprint_r($query);returns options on the top level, not within the options object. IIRC it used to be like that a long time ago.