X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fpq%2FGateway%2FTable%2FOptimisticLock.php;h=4b22f575e6a4e30216b1e66831e8e7137e63d16a;hb=ccdcd2977c8bdc7c74b89b2fb7c2ea46479692b8;hp=08e5ae364f687f2e019cc633d83dc7c72542c897;hpb=580991717f5e8bb237403757e2111a8d04aca616;p=m6w6%2Fpq-gateway diff --git a/lib/pq/Gateway/Table/OptimisticLock.php b/lib/pq/Gateway/Table/OptimisticLock.php index 08e5ae3..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 } /** - * @implements LockInterface + * @param \pq\Gateway\Table $table * @param \pq\Gateway\Row $row + * @param string $event create/update/delete * @param array $where reference to the criteria */ - function criteria(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); + } } }