Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9965

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Inserts a document into the collection</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocollection.group.html">MongoCollection::group</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocollection.parallelcollectionscan.html">MongoCollection::parallelCollectionScan</a></div>
 <div class="up"><a href="class.mongocollection.html">MongoCollection</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongocollection.insert" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCollection::insert</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoCollection::insert</span> &mdash; <span class="dc-title">Inserts a document into the collection</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocollection.insert-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><span class="type bool|array">bool|array</span></span> <span class="methodname"><strong>MongoCollection::insert</strong></span>
    ( <span class="methodparam"><span class="type"><span class="type array|object">array|object</span></span> <code class="parameter">$document</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code><span class="initializer"> = array()</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   All strings sent to the database must be UTF-8.  If a string is not UTF-8, a 
   <a href="class.mongoexception.html" class="classname">MongoException</a> will be thrown.  To insert 
   (or query for) a non-UTF-8 string, use <a href="class.mongobindata.html" class="classname">MongoBinData</a>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongocollection.insert-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">document</code>
     </dt>

     <dd>

      <p class="para">
       An array or object. If an object is used, it may not have protected or
       private properties.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        If the parameter does not have an <em>_id</em> key or
        property, a new <a href="class.mongoid.html" class="classname">MongoId</a> instance will be created
        and assigned to it. This special behavior does not mean that the
        parameter is passed by reference.
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>

      <code class="parameter">options</code>
     </dt>

     <dd>

      <p class="para">
       An array of options for the insert operation. Currently available options
       include:
       <ul class="itemizedlist">
        <li class="listitem"><p class="para"><em>&quot;fsync&quot;</em></p><p class="para">Boolean, defaults to <strong><code>FALSE</code></strong>. If journaling is enabled, it works exactly like <em>&quot;j&quot;</em>. If journaling is not enabled, the write operation blocks until it is synced to database files on disk. If <strong><code>TRUE</code></strong>, an acknowledged insert is implied and this option will override setting <em>&quot;w&quot;</em> to <em>0</em>.</p><blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">If journaling is enabled, users are strongly encouraged to use the <em>&quot;j&quot;</em> option instead of <em>&quot;fsync&quot;</em>. Do not use <em>&quot;fsync&quot;</em> and <em>&quot;j&quot;</em> simultaneously, as that will result in an error.</span></p></blockquote></li>
        <li class="listitem"><p class="para"><em>&quot;j&quot;</em></p><p class="para">Boolean, defaults to <strong><code>FALSE</code></strong>. Forces the write operation to block until it is synced to the journal on disk. If <strong><code>TRUE</code></strong>, an acknowledged write is implied and this option will override setting <em>&quot;w&quot;</em> to <em>0</em>.</p><blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">If this option is used and journaling is disabled, MongoDB 2.6+ will raise an error and the write will fail; older server versions will simply ignore the option.</span></p></blockquote></li>
        <li class="listitem"><p class="para"><em>&quot;socketTimeoutMS&quot;</em></p><p class="para">This option specifies the time limit, in milliseconds, for socket communication. If the server does not respond within the timeout period, a <a href="class.mongocursortimeoutexception.html" class="classname">MongoCursorTimeoutException</a> will be thrown and there will be no way to determine if the server actually handled the write or not. A value of <em>-1</em> may be specified to block indefinitely. The default value for <a href="class.mongoclient.html" class="classname">MongoClient</a> is <em>30000</em> (30 seconds).</p></li>
        <li class="listitem"><p class="para"><em>&quot;w&quot;</em></p><p class="para">See <a href="mongo.writeconcerns.html" class="link">Write Concerns</a>. The default value for <a href="class.mongoclient.html" class="classname">MongoClient</a> is <em>1</em>.</p></li>
        <li class="listitem"><p class="para"><em>&quot;wTimeoutMS&quot;</em></p><p class="para">This option specifies the time limit, in milliseconds, for <a href="mongo.writeconcerns.html" class="link">write concern</a> acknowledgement. It is only applicable when <em>&quot;w&quot;</em> is greater than <em>1</em>, as the timeout pertains to replication. If the write concern is not satisfied within the time limit, a <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> will be thrown. A value of <em>0</em> may be specified to block indefinitely. The default value for <a href="class.mongoclient.html" class="classname">MongoClient</a> is <em>10000</em> (ten seconds).</p></li>
       </ul>
      </p>
      <p class="para">
       The following options are deprecated and should no longer be used:
       <ul class="itemizedlist">
        <li class="listitem"><p class="para"><em>&quot;safe&quot;</em></p><p class="para">Deprecated. Please use the <a href="mongo.writeconcerns.html" class="link">write concern</a> <em>&quot;w&quot;</em> option.</p></li>
        <li class="listitem"><p class="para"><em>&quot;timeout&quot;</em></p><p class="para">Deprecated alias for <em>&quot;socketTimeoutMS&quot;</em>.</p></li>
        <li class="listitem"><p class="para"><em>&quot;wtimeout&quot;</em></p><p class="para">Deprecated alias for <em>&quot;wTimeoutMS&quot;</em>.</p></li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocollection.insert-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array containing the status of the insertion if the
   <em>&quot;w&quot;</em> option is set. Otherwise, returns <strong><code>TRUE</code></strong> if the
   inserted array is not empty (a <a href="class.mongoexception.html" class="classname">MongoException</a> will be
   thrown if the inserted array is empty).
  </p>
  <p class="para">
   If an array is returned, the following keys may be present:
   <dl>

    
     <dt>

      <code class="parameter">ok</code>
     </dt>

     <dd>

      <p class="para">
       This should almost always be 1 (unless last_error itself failed).
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">err</code>
     </dt>

     <dd>

      <p class="para">
       If this field is non-null, an error occurred on the previous operation.
       If this field is set, it will be a string describing the error that
       occurred. 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">code</code>
     </dt>

     <dd>

      <p class="para">
       If a database error occurred, the relevant error code will be passed
       back to the client. 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">errmsg</code>
     </dt>

     <dd>

      <p class="para">
       This field is set if something goes wrong with a database command. It
       is coupled with <em>ok</em> being 0. For example, if
       <em>w</em> is set and times out, errmsg will be set to &quot;timed
       out waiting for slaves&quot; and <em>ok</em> will be 0.  If this
       field is set, it will be a string describing the error that occurred. 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">n</code>
     </dt>

     <dd>

      <p class="para">
       If the last operation was an update, upsert, or a remove, the number
       of documents affected will be returned. For insert operations, this value
       is always <em>0</em>.
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">wtimeout</code>
     </dt>

     <dd>

      <p class="para">
       If the previous option timed out waiting for replication. 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">waited</code>
     </dt>

     <dd>

      <p class="para">
       How long the operation waited before timing out. 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">wtime</code>
     </dt>

     <dd>

      <p class="para">
       If <em>w</em> was set and the operation succeeded, how long it took to
       replicate to <em>w</em> servers. 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">upserted</code>
     </dt>

     <dd>

      <p class="para">
       If an upsert occurred, this field will contain the new record&#039;s
       <em>_id</em> field. For upserts, either this field or
       <em>updatedExisting</em> will be present (unless an error
       occurred). 
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">updatedExisting</code>
     </dt>

     <dd>

      <p class="para">
       If an upsert updated an existing element, this field will be true. For
       upserts, either this field or upserted will be present (unless an error
       occurred). 
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongocollection.insert-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws <a href="class.mongoexception.html" class="classname">MongoException</a> if the inserted document is
   empty or if it contains zero-length keys. Attempting to insert an object with
   protected and private properties will cause a zero-length key error.
  </p>
  <p class="para">Throws <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> if the <em>&quot;w&quot;</em> option is set and the write fails.</p><p class="para">Throws <a href="class.mongocursortimeoutexception.html" class="classname">MongoCursorTimeoutException</a> if the <em>&quot;w&quot;</em> option is set to a value greater than one and the operation takes longer than <var class="varname"><var class="varname">MongoCursor::$timeout</var></var> milliseconds to complete.  This does not kill the operation on the server, it is a client-side timeout. The operation in <var class="varname"><var class="varname">MongoCollection::$wtimeout</var></var> is milliseconds.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongocollection.insert-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>1.5.0</td>
       <td>
        <p class="para">
         Added the <em>&quot;wTimeoutMS&quot;</em> option, which replaces
         <em>&quot;wtimeout&quot;</em>. Emits <strong><code>E_DEPRECATED</code></strong>
         when <em>&quot;wtimeout&quot;</em> is used.
        </p>
        <p class="para">
         Added the <em>&quot;socketTimeoutMS&quot;</em> option, which replaces
         <em>&quot;timeout&quot;</em>. Emits <strong><code>E_DEPRECATED</code></strong>
         when <em>&quot;timeout&quot;</em> is used.
        </p>
        <p class="para">
         Emits <strong><code>E_DEPRECATED</code></strong> when <em>&quot;safe&quot;</em>
         is used.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.3.4</td>
       <td>Added <em>&quot;wtimeout&quot;</em> option.</td>
      </tr>

      <tr>
       <td>1.3.0</td>
       <td>
        <p class="para">Added <em>&quot;w&quot;</em> option.</p>
        <p class="para">
         The <code class="parameter">options</code> parameter no longer accepts a
         boolean to signify an acknowledged write. Instead, this now has to be
         done with <em>array(&#039;w&#039; =&gt; 1)</em> (the default behaviour of
         <a href="class.mongoclient.html" class="classname">MongoClient</a>).
        </p>
       </td>
      </tr>

      <tr>
       <td>1.2.0</td>
       <td>Added <em>&quot;timeout&quot;</em> option.</td>
      </tr>

      <tr>
       <td>1.0.11</td>
       <td>
        Disconnects on &quot;not master&quot; errors if <em>&quot;safe&quot;</em> is set.
       </td>
      </tr>

      <tr>
       <td>1.0.9</td>
       <td>
        <p class="para">
         Added ability to pass integers to the <em>&quot;safe&quot;</em> option,
         which previously only accepted booleans.
        </p>
        <p class="para">
         Added <em>&quot;fsync&quot;</em> option.
        </p>
        <p class="para">
         The return type was changed to be an array containing error information
         if the <em>&quot;safe&quot;</em> option is used. Otherwise, a boolean
         is returned as before.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.0.2</td>
       <td>
        Changed second parameter to be an array of options. Pre-1.0.2, the
        second parameter was a boolean indicating the <em>&quot;safe&quot;</em>
        option.
       </td>
      </tr>

      <tr>
       <td>1.0.1</td>
       <td>
        Throw a <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> if the
        <em>&quot;safe&quot;</em> option is set and the insert fails.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocollection.insert-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1601">
   <p><strong>Example #1 <span class="function"><strong>MongoCollection::insert()</strong></span> <em>_id</em> example</strong></p>
   <div class="example-contents"><p>
    An <em>_id</em> field will be added to the inserted document if
    not already present. Depending on how the parameter is passed, a generated
    <em>_id</em> may or may not be available to calling code.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$collection&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">'test'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpmanual'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;If&nbsp;an&nbsp;array&nbsp;literal&nbsp;is&nbsp;used,&nbsp;there&nbsp;is&nbsp;no&nbsp;way&nbsp;to&nbsp;access&nbsp;the&nbsp;generated&nbsp;_id<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'x'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">//&nbsp;The&nbsp;_id&nbsp;is&nbsp;available&nbsp;on&nbsp;an&nbsp;array&nbsp;passed&nbsp;by&nbsp;value<br /></span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'x'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;The&nbsp;_id&nbsp;is&nbsp;not&nbsp;available&nbsp;on&nbsp;an&nbsp;array&nbsp;passed&nbsp;by&nbsp;reference<br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'x'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$ref&nbsp;</span><span style="color: #007700">=&nbsp;&amp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #0000BB">$ref</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$ref</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;The&nbsp;_id&nbsp;is&nbsp;available&nbsp;if&nbsp;a&nbsp;wrapping&nbsp;function&nbsp;does&nbsp;not&nbsp;trigger&nbsp;copy-on-write<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">insert_no_cow</span><span style="color: #007700">(</span><span style="color: #0000BB">$collection</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$document</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #0000BB">$document</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'x'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">insert_no_cow</span><span style="color: #007700">(</span><span style="color: #0000BB">$collection</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;The&nbsp;_id&nbsp;is&nbsp;not&nbsp;available&nbsp;if&nbsp;a&nbsp;wrapping&nbsp;function&nbsp;triggers&nbsp;copy-on-write<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">insert_cow</span><span style="color: #007700">(</span><span style="color: #0000BB">$collection</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$document</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$document</span><span style="color: #007700">[</span><span style="color: #DD0000">'y'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #0000BB">$document</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$d&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'x'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">insert_cow</span><span style="color: #007700">(</span><span style="color: #0000BB">$collection</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$d</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$d</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(2) {
  [&quot;x&quot;]=&gt;
  int(2)
  [&quot;_id&quot;]=&gt;
  object(MongoId)#4 (0) {
  }
}
array(1) {
  [&quot;x&quot;]=&gt;
  int(3)
}
array(2) {
  [&quot;x&quot;]=&gt;
  int(4)
  [&quot;_id&quot;]=&gt;
  object(MongoId)#5 (0) {
  }
}
array(1) {
  [&quot;x&quot;]=&gt;
  int(5)
}
</pre></div>
   </div>
  </div>

  <div class="example" id="example-1602">
   <p><strong>Example #2 <span class="function"><strong>MongoCollection::insert()</strong></span> acknowledged write example</strong></p>
   <div class="example-contents"><p>
    This example shows inserting two elements with the same _id, which causes 
    a <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> to be thrown, as 
    <code class="parameter">w</code> was set.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$person&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Joe"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"age"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #0000BB">$person</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;now&nbsp;$person&nbsp;has&nbsp;an&nbsp;_id&nbsp;field,&nbsp;so&nbsp;if&nbsp;we&nbsp;save&nbsp;it&nbsp;<br />//&nbsp;again,&nbsp;we&nbsp;will&nbsp;get&nbsp;an&nbsp;exception<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #0000BB">$person</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"w"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br />}&nbsp;catch(</span><span style="color: #0000BB">MongoCursorException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Can't&nbsp;save&nbsp;the&nbsp;same&nbsp;person&nbsp;twice!\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocollection.insert-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="mongocollection.batchinsert.html" class="function" rel="rdfs-seeAlso">MongoCollection::batchInsert()</a> - Inserts multiple documents into this collection</span></li>
   <li class="member"><span class="function"><a href="mongocollection.update.html" class="function" rel="rdfs-seeAlso">MongoCollection::update()</a> - Update records based on a given criteria</span></li>
   <li class="member"><span class="function"><a href="mongocollection.find.html" class="function" rel="rdfs-seeAlso">MongoCollection::find()</a> - Queries this collection, returning a MongoCursor
  for the result set</span></li>
   <li class="member"><span class="function"><a href="mongocollection.remove.html" class="function" rel="rdfs-seeAlso">MongoCollection::remove()</a> - Remove records from this collection</span></li>
   <li class="member">MongoDB core docs on <a href="https://docs.mongodb.com/manual/tutorial/insert-documents/" class="link external">&raquo;&nbsp;insert</a>.</li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocollection.group.html">MongoCollection::group</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocollection.parallelcollectionscan.html">MongoCollection::parallelCollectionScan</a></div>
 <div class="up"><a href="class.mongocollection.html">MongoCollection</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>