X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fpq%2FGateway%2FTable%2FOptimisticLock.php;h=4b22f575e6a4e30216b1e66831e8e7137e63d16a;hb=d3a497c12f60567cbb20ea626fd909f94955ebac;hp=8c2ec7b9741cb52b57e4c6bee3fdf9294726a81b;hpb=3c8b32baaac62855e2c9f5bfdb5ede9685ce2b76;p=m6w6%2Fpq-gateway diff --git a/lib/pq/Gateway/Table/OptimisticLock.php b/lib/pq/Gateway/Table/OptimisticLock.php index 8c2ec7b..4b22f57 100644 --- a/lib/pq/Gateway/Table/OptimisticLock.php +++ b/lib/pq/Gateway/Table/OptimisticLock.php @@ -7,7 +7,7 @@ use \pq\Gateway\Row; /** * An optimistic row lock implementation using a versioning column */ -class OptimisticLock implements LockInterface +class OptimisticLock implements \SplObserver { /** * The name of the versioning column @@ -23,12 +23,15 @@ class OptimisticLock implements LockInterface } /** - * @inheritdoc + * @param \pq\Gateway\Table $table * @param \pq\Gateway\Row $row + * @param string $event create/update/delete * @param array $where reference to the criteria */ - function onUpdate(Row $row, array &$where) { - $where["{$this->column}="] = $row->getData()[$this->column]; - $row->{$this->column}->mod(+1); + function update(\SplSubject $table, Row $row = null, $event = null, array &$where = null) { + if ($event === "update") { + $where["{$this->column}="] = $row->getData()[$this->column]; + $row->{$this->column}->mod(+1); + } } }