Documentation Home
MySQL PHP API
Download this Manual
PDF (US Ltr) - 2.4Mb
PDF (A4) - 2.4Mb
HTML Download (TGZ) - 250.9Kb
HTML Download (Zip) - 258.4Kb


MySQL PHP API  /  ...  /  CollectionFind::lockShared

5.8.9 CollectionFind::lockShared

Copyright 1997-2019 the PHP Documentation Group.

  • CollectionFind::lockShared

    Execute operation with SHARED LOCK

Description

public mysql_xdevapi\CollectionFind mysql_xdevapi\CollectionFind::lockShared(integer lock_waiting_option);

Allows to share the documents between multiple transactions which are locking in shared mode.

Other sessions can read the rows, but cannot modify them until your transaction commits.

If any of these rows were changed by another transaction that has not yet committed,

your query waits until that transaction ends and then uses the latest values.

Parameters

lock_waiting_option

Optional waiting option. By default it is MYSQLX_LOCK_DEFAULT. Valid values are these constants:

  • MYSQLX_LOCK_DEFAULT

  • MYSQLX_LOCK_NOWAIT

  • MYSQLX_LOCK_SKIP_LOCKED

Return Values

A CollectionFind object that can be used for further processing

Examples

Example 5.36 mysql_xdevapi\CollectionFind::lockShared example

<?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();
?>