©
本文档使用
php.cn手册 发布
(mongodb >=1.0.0)
MongoDB\Driver\Cursor::toArray — Returns an array containing all results for this cursor
Iterates the cursor and returns its results in an array. MongoDB\Driver\Cursor::setTypeMap() may be used to control how documents are unserialized into PHP values.
此函数没有参数。
Returns an array containing all results for this cursor.
Example #1 MongoDB\Driver\Cursor::toArray() example
<?php
$manager = new MongoDB \ Driver \ Manager ( "mongodb://localhost:27017" );
$bulk = new MongoDB \ Driver \ BulkWrite ;
$bulk -> insert ([ 'x' => 1 ]);
$bulk -> insert ([ 'x' => 2 ]);
$bulk -> insert ([ 'x' => 3 ]);
$manager -> executeBulkWrite ( 'db.collection' , $bulk );
$query = new MongoDB \ Driver \ Query ([]);
$cursor = $manager -> executeQuery ( 'db.collection' , $query );
var_dump ( $cursor -> toArray ());
?>
以上例程的输出类似于:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|