- function onUpdate(Row $row, array &$ignore) {
- $where = array();
- foreach ($row->getIdentity() as $col => $val) {
- if (isset($val)) {
- $where["$col="] = $val;
- } else {
- $where["$col IS"] = new QueryExpr("NULL");
+ function update(\SplSubject $table, Row $row = null, $event = null, array &$where = null) {
+ if ($event === "update") {
+ if (1 != count($rowset = $table->find($where, null, 0, 0, "update nowait"))) {
+ throw new \UnexpectedValueException("Failed to select a single row");
+ }
+ if ($rowset->current()->getData() != $row->getData()) {
+ throw new \UnexpectedValueException("Row has already been modified");