2017 © Pedro Peláez
 

yii-extension yii2-lockable-activerecord

Pessimistic locking behavior for Yii2 ActiveRecord

image

yii-dream-team/yii2-lockable-activerecord

Pessimistic locking behavior for Yii2 ActiveRecord

  • Thursday, August 3, 2017
  • by lagman
  • Repository
  • 4 Watchers
  • 11 Stars
  • 3,896 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 43 % Grown

The README.md

Pessimistic locking behavior for Yii2 ActiveRecord

This package allows you to use pessimistic locking (select for update) when you work with ActiveRecord models., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist yii-dream-team/yii2-lockable-activerecord "*"

or add, (*4)

"yii-dream-team/yii2-lockable-activerecord": "*"

to the require section of your composer.json., (*5)

Usage

Attach the behavior to your controller class., (*6)

public function behaviors()
{
    return [
        '\yiidreamteam\behaviors\LockableActiveRecord',
    ];
}

Add @mixin phpdoc to you class definition., (*7)

/**
 * Class Sample
 * @package common\models
 *
 * @mixin \yiidreamteam\behaviors\LockableActiveRecord
 */
class Sample extends ActiveRecord { ... }

Use model locks in transaction., (*8)

$dbTransaction = $model->getDb()->beginTransaction(\yii\db\Transaction::SERIALIZABLE);
try {
    $model->lock();
    $model->doSomethingWhileLocked();
    $dbTransaction->commit();
} catch(\Exception $e) {
    $dbTransaction->rollBack();
    throw $e;
}

Licence

MIT, (*9)

The Versions

03/08 2017

dev-master

9999999-dev

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock

03/08 2017

1.0.5

1.0.5.0

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock

29/09 2015

1.0.4

1.0.4.0

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock

16/07 2015

1.0.2

1.0.2.0

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock

16/07 2015

1.0.3

1.0.3.0

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock

16/07 2015

1.0.1

1.0.1.0

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock

23/03 2015

1.0.0

1.0.0.0

Pessimistic locking behavior for Yii2 ActiveRecord

  Sources   Download

MIT

The Requires

 

yii2 behavior activerecord lock