<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="mysql-xdevapi-collectionfind.lockshared" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>CollectionFind::lockShared</refname>
  <refpurpose>Execute operation with SHARED LOCK</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>mysql_xdevapi\CollectionFind</type><methodname>mysql_xdevapi\CollectionFind::lockShared</methodname>
   <methodparam choice="opt"><type>int</type><parameter>lock_waiting_option</parameter></methodparam>
  </methodsynopsis>
  <para>
   Allows to share the documents between multiple transactions which are locking in shared mode.
  </para>
  <para>
   Other sessions can read the rows, but cannot modify them until your transaction commits. 
  </para>
  <para>
   If any of these rows were changed by another transaction that has not yet committed, 
  </para>
  <para>
   your query waits until that transaction ends and then uses the latest values.
  </para>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>lock_waiting_option</parameter></term>
    <listitem>
     <para>
      Optional waiting option. By default it is <constant>MYSQLX_LOCK_DEFAULT</constant>. Valid values are these constants:
     </para>
     <itemizedlist>
      <listitem><para><constant>MYSQLX_LOCK_DEFAULT</constant></para></listitem>
      <listitem><para><constant>MYSQLX_LOCK_NOWAIT</constant></para></listitem>
      <listitem><para><constant>MYSQLX_LOCK_SKIP_LOCKED</constant></para></listitem>
     </itemizedlist>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   A CollectionFind object that can be used for further processing
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>mysql_xdevapi\CollectionFind::lockShared</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");

$schema     = $session->getSchema("addressbook");
$collection = $schema->createCollection("people");

$session->startTransaction();

$result = $collection
  ->find("age > 50")
  ->lockShared()
  ->execute();

// ... read the object in shared mode

// Complete the transaction and unlock the document
$session->commit();
?>
]]>
   </programlisting>
  </example>
 </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
-->
