mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@333956 c90b9560-bf6c-de11-be94-00142212c4b1
201 lines
6.9 KiB
XML
201 lines
6.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: d5a500831e9e6e708b64b337d70edb50f6e6989a Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: no Maintainer: seros -->
|
|
|
|
<phpdoc:classref xml:id="class.mongowritebatch" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>La clase MongoWriteBatch</title>
|
|
<titleabbrev>MongoWriteBatch</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ MongoWriteBatch intro -->
|
|
<section xml:id="mongowritebatch.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
MongoWriteBatch es la clase base para las clases <classname>MongoInsertBatch</classname>,
|
|
<classname>MongoUpdateBatch</classname> y <classname>MongoDeleteBatch</classname>.
|
|
</para>
|
|
<para>
|
|
MongoWriteBatch permite crear lotes de varias operaciones (del mismo tipo) y enviarlos
|
|
a MongoDB a la vez. Esto puede ser especialmente útil al operar sobre muchos documentos al
|
|
mismo tiempo para reducir los viajes de ida y vuelta.
|
|
</para>
|
|
<para>
|
|
Antes de la versión 1.5.0 del controlador, era posible utilizar <methodname>MongoCollection::batchInsert</methodname>,
|
|
sin embargo, a partir de la versión 1.5.0 no se recomientda dicho método.
|
|
</para>
|
|
<para>
|
|
Nota: Esta clase solamente está disponible al conversar con servidores de MongoDB 2.6.0 (y posteriores). Se lanzará
|
|
una <classname>MongoProtocolException</classname> si se intenta usarla con versiones de MongoDB más antiguas.
|
|
</para>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="mongowritebatch.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass><classname>MongoWriteBatch</classname></ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<classname>MongoWriteBatch</classname>
|
|
</ooclass>
|
|
</classsynopsisinfo>
|
|
<!-- }}} -->
|
|
|
|
<classsynopsisinfo role="comment">&Constants;</classsynopsisinfo>
|
|
<fieldsynopsis>
|
|
<modifier>const</modifier>
|
|
<type>int</type>
|
|
<varname linkend="mongowritebatch.constants.command.insert">MongoWriteBatch::COMMAND_INSERT</varname>
|
|
<initializer>1</initializer>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>const</modifier>
|
|
<type>int</type>
|
|
<varname linkend="mongowritebatch.constants.command.update">MongoWriteBatch::COMMAND_UPDATE</varname>
|
|
<initializer>2</initializer>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>const</modifier>
|
|
<type>int</type>
|
|
<varname linkend="mongowritebatch.constants.command.delete">MongoWriteBatch::COMMAND_DELETE</varname>
|
|
<initializer>3</initializer>
|
|
</fieldsynopsis>
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongowritebatch')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])" />
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongowritebatch')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="mongowritebatch.constants">
|
|
<title>MongoWriteBatch types</title>
|
|
<variablelist>
|
|
|
|
<varlistentry xml:id="mongowritebatch.constants.command.insert">
|
|
<term><constant>MongoWriteBatch::COMMAND_INSERT</constant></term>
|
|
<listitem>
|
|
<para>Crear un lote de escritura de inserciones</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry xml:id="mongowritebatch.constants.command.update">
|
|
<term><constant>MongoWriteBatch::COMMAND_UPDATE</constant></term>
|
|
<listitem>
|
|
<para>Crear un lote de escritura de actualizaciones</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry xml:id="mongowritebatch.constants.command.delete">
|
|
<term><constant>MongoWriteBatch::COMMAND_DELETE</constant></term>
|
|
<listitem>
|
|
<para>Crear un lote de escritura de eliminaciones</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
</section>
|
|
</section>
|
|
|
|
<section xml:id="mongowritebatch.description">
|
|
&reftitle.description;
|
|
<para>
|
|
Al ejecutar un lote, invocando a <methodname>MongoWriteBatch::execute</methodname>, MongoWriteBatch enviará
|
|
<link xlink:href="url.mongodb.dochub.maxWriteBatchSize">maxWriteBatchSize</link> (predeterminado a 1000) documentos o
|
|
hasta <link xlink:href="url.mongodb.dochub.maxBsonObjectSize">maxBsonObjectSize</link> (predeterminado a 16777216 bytes), lo que ocurra primero.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Los documentos nunca se transferirán parcialmente. Si se añade al lote un documento que sobrepase el límte,
|
|
se creará un nuevo lote donde se colocará dicho documento.
|
|
</para>
|
|
</note>
|
|
</section>
|
|
|
|
<section xml:id="mongowritebatch.errors">
|
|
&reftitle.errors;
|
|
<simplelist>
|
|
<member><classname>Exception</classname> en fallos de análisis de parámetros</member>
|
|
<member><classname>Exception</classname> en errores de validación de argumentos (p.ej., claves ausentes)</member>
|
|
<member><classname>MongoProtocolException</classname> cuando se conversa con servidores de MongoDB más antiguos que 2.6.0.</member>
|
|
<member><classname>MongoProtocolException</classname> en errores de socket.</member>
|
|
<member><classname>MongoWriteConcernException</classname> cuando falla una escritura debido a <link linkend="mongo.writeconcerns">WriteConcerns</link></member>
|
|
</simplelist>
|
|
</section>
|
|
|
|
<section xml:id="mongowritebatch.examples">
|
|
&reftitle.examples;
|
|
<example xml:id="mongowritebatch.example.basic">
|
|
<title>Ejemplo de <classname>MongoWriteBatch</classname></title>
|
|
<para>
|
|
Añadir documentos a un lote de Insert y ejecutarlo
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$mc = new MongoClient("localhost");
|
|
|
|
$colección = $mc->selectCollection("prueba", "prueba");
|
|
|
|
|
|
$docs = array();
|
|
$docs[] = array("my" => "demo");
|
|
$docs[] = array("is" => "working");
|
|
$docs[] = array("pretty" => "well");
|
|
|
|
$lote = new MongoInsertBatch($colección);
|
|
foreach($docs as $documento) {
|
|
$lote->add($documento);
|
|
}
|
|
$retval = $lote->execute(array("w" => 1));
|
|
var_dump($retval);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
array(2) {
|
|
["nInserted"]=>
|
|
int(3)
|
|
["ok"]=>
|
|
bool(true)
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
&reference.mongo.entities.mongowritebatch;
|
|
|
|
</phpdoc:classref>
|
|
|
|
<!-- 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
|
|
-->
|