mysql_xdevapi\CollectionFind
PHP Manual

CollectionFind::lockShared

(No version information available, might only be in Git)

CollectionFind::lockSharedExecute operation with SHARED LOCK

说明

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.

参数

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

返回值

A CollectionFind object that can be used for further processing

范例

Example #1 mysql_xdevapi\CollectionFind::lockShared() example

<?php

//Assuming $coll is a valid Collection object and $session is a valid Session Object

$session->startTransaction();

//Returns all the documents with 'age' greather than 50 and attempt to lock them
$res $col1->find("age > 50")->lockShared()->execute();

//Read the document in shared mode ..
//...

//Complete the transaction and unlock the document
$session->commit();


?>

mysql_xdevapi\CollectionFind
PHP Manual