array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'mongodb-driver-cursor.toarray.php', 1 => 'MongoDB\\Driver\\Cursor::toArray', ), 'up' => array ( 0 => 'class.mongodb-driver-cursor.php', 1 => 'MongoDB\\Driver\\Cursor', ), 'prev' => array ( 0 => 'mongodb-driver-cursor.settypemap.php', 1 => 'MongoDB\\Driver\\Cursor::setTypeMap', ), 'next' => array ( 0 => 'mongodb-driver-cursor.valid.php', 1 => 'MongoDB\\Driver\\Cursor::valid', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mongodb/mongodb/driver/cursor/toarray.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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.
Bu işlevin bağımsız değişkeni yoktur.
Returns an array containing all results for this cursor.
Örnek 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());
?>
Yukarıdaki örnek şuna benzer bir çıktı üretir:
array(3) { [0]=> object(stdClass)#6 (2) { ["_id"]=> object(MongoDB\BSON\ObjectId)#5 (1) { ["oid"]=> string(24) "564259a96118fd40b41bcf61" } ["x"]=> int(1) } [1]=> object(stdClass)#8 (2) { ["_id"]=> object(MongoDB\BSON\ObjectId)#7 (1) { ["oid"]=> string(24) "564259a96118fd40b41bcf62" } ["x"]=> int(2) } [2]=> object(stdClass)#10 (2) { ["_id"]=> object(MongoDB\BSON\ObjectId)#9 (1) { ["oid"]=> string(24) "564259a96118fd40b41bcf63" } ["x"]=> int(3) } }