3 namespace pq\Gateway\Table
;
8 * An optimistic row lock implementation using a versioning column
10 class OptimisticLock
implements \SplObserver
13 * The name of the versioning column
19 * @param string $column
21 function __construct($column = "version") {
22 $this->column
= $column;
26 * @param \pq\Gateway\Table $table
27 * @param \pq\Gateway\Row $row
28 * @param string $event create/update/delete
29 * @param array $where reference to the criteria
31 function update(\SplSubject
$table, Row
$row = null, $event = null, array &$where = null) {
32 if ($event === "update") {
33 $where["{$this->column}="] = $row->getData()[$this->column
];
34 $row->{$this->column
}->mod(+
1);