<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mysql-xdevapi-collectionfind.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'mysql-xdevapi-collectionfind.lockexclusive.php',
    1 => 'CollectionFind::lockExclusive',
    2 => 'Execute operation with EXCLUSIVE LOCK',
  ),
  'up' => 
  array (
    0 => 'class.mysql-xdevapi-collectionfind.php',
    1 => 'mysql_xdevapi\\CollectionFind',
  ),
  'prev' => 
  array (
    0 => 'mysql-xdevapi-collectionfind.limit.php',
    1 => 'CollectionFind::limit',
  ),
  'next' => 
  array (
    0 => 'mysql-xdevapi-collectionfind.lockshared.php',
    1 => 'CollectionFind::lockShared',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mysql_xdevapi/mysql_xdevapi/collectionfind/lockexclusive.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mysql-xdevapi-collectionfind.lockexclusive" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">CollectionFind::lockExclusive</h1>
  <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">CollectionFind::lockExclusive</span> &mdash; <span class="dc-title">Execute operation with EXCLUSIVE LOCK</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysql-xdevapi-collectionfind.lockexclusive-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>mysql_xdevapi\CollectionFind::lockExclusive</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$lock_waiting_option</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.mysql-xdevapi-collectionfind.php" class="type mysql_xdevapi\CollectionFind">mysql_xdevapi\CollectionFind</a></span></div>

  <p class="para rdfs-comment">
   Locks the document exclusively.
   As long as the document is locked,
   other transactions can&#039;t update the document,
   use <code class="code">SELECT ... LOCK IN SHARE MODE</code>,
   or read the data in certain transaction isolation levels.
   Consistent reads ignore any locks set on the records that exist in the read view.
  </p>
  <p class="para">
   To avoid concurrency problems, it makes sense to use this function with the
   <span class="methodname"><strong>mysql_xdevapi\Collection::modify()</strong></span> method. Essentially, this function uses row locks to serialise
   access to rows.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysql-xdevapi-collectionfind.lockexclusive-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">lock_waiting_option</code></dt>
    <dd>
     <p class="para">
      Optional waiting option. By default it is <strong><code><a href="mysql-xdevapi.constants.php#constant.mysqlx-lock-default">MYSQLX_LOCK_DEFAULT</a></code></strong>. Valid values are these constants:
     </p>
     <ul class="itemizedlist">
      <li class="listitem"><p class="para"><strong><code><a href="mysql-xdevapi.constants.php#constant.mysqlx-lock-default">MYSQLX_LOCK_DEFAULT</a></code></strong></p></li>
      <li class="listitem"><p class="para"><strong><code><a href="mysql-xdevapi.constants.php#constant.mysqlx-lock-nowait">MYSQLX_LOCK_NOWAIT</a></code></strong></p></li>
      <li class="listitem"><p class="para"><strong><code><a href="mysql-xdevapi.constants.php#constant.mysqlx-lock-skip-locked">MYSQLX_LOCK_SKIP_LOCKED</a></code></strong></p></li>
     </ul>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysql-xdevapi-collectionfind.lockexclusive-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a CollectionFind object that can be used for further processing.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mysql-xdevapi-collectionfind.lockexclusive-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="function"><strong>mysql_xdevapi\CollectionFind::lockExclusive()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$session </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_xdevapi\getSession</span><span style="color: #007700">(</span><span style="color: #DD0000">"mysqlx://user:password@localhost"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$schema     </span><span style="color: #007700">= </span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSchema</span><span style="color: #007700">(</span><span style="color: #DD0000">"addressbook"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$collection </span><span style="color: #007700">= </span><span style="color: #0000BB">$schema</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"people"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">startTransaction</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$collection<br />  </span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">(</span><span style="color: #DD0000">"age &gt; 50"</span><span style="color: #007700">)<br />  -&gt;</span><span style="color: #0000BB">lockExclusive</span><span style="color: #007700">()<br />  -&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// ... do an operation on the object<br /><br />// Complete the transaction and unlock the document<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">commit</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


</div><?php manual_footer($setup); ?>