mirror of
https://github.com/php/doc-ru.git
synced 2025-08-13 15:20:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@350139 c90b9560-bf6c-de11-be94-00142212c4b1
139 lines
3.4 KiB
XML
139 lines
3.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- $Revision$ -->
|
||
<!-- EN-Revision: 2c423ff085531b5a614c7b10c2d8cf957cdda808 Maintainer: lex Status: ready -->
|
||
<!-- Reviewed: yes Maintainer: sergey -->
|
||
|
||
<refentry xml:id="mongodb-driver-cursor.toarray" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>MongoDB\Driver\Cursor::toArray</refname>
|
||
<refpurpose>Возвращает массив, содержащий все результаты курсора</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<modifier>final</modifier> <modifier>public</modifier> <type>array</type><methodname>MongoDB\Driver\Cursor::toArray</methodname>
|
||
<void />
|
||
</methodsynopsis>
|
||
<para>
|
||
Итерирует курсор и возвращает его результаты в виде массива.
|
||
<function>MongoDB\Driver\Cursor::setTypeMap</function> может использоваться для управления тем,
|
||
как документы десериализованы в значение PHP.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
&no.function.parameters;
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
Возвращает массив (<type>array</type>), содержащий все результаты курсора.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="errors">
|
||
&reftitle.errors;
|
||
<simplelist>
|
||
&mongodb.throws.argumentparsing;
|
||
</simplelist>
|
||
</refsect1>
|
||
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<example>
|
||
<title>Пример использования <function>MongoDB\Driver\Cursor::toArray</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?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());
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs.similar;
|
||
<screen>
|
||
<![CDATA[
|
||
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)
|
||
}
|
||
}
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</refsect1>
|
||
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<simplelist>
|
||
<member><function>MongoDB\Driver\Cursor::setTypeMap</function></member>
|
||
</simplelist>
|
||
</refsect1>
|
||
|
||
</refentry>
|
||
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|