public function update(DataInterface $data) { $updator = new RowUpdator($this->table_name); $dirty_data = $data->getDirty(); if (empty($dirty_data)) { return true; } foreach ($dirty_data as $field => $value) { $updator->set($field, $value); } foreach ($data->id() as $field => $value) { $updator->by($field, $value); break; } return $updator->update(); }
private function update() { RowUpdator::beginTransaction(); try { if ($this->beforeUpdate() === false) { RowUpdator::rollback(); return false; } $this->relation_ship->save(); $Entity = get_called_class(); (new Mapper())->selectTable($Entity::getTableName())->update($this->data); $this->relation_ship->saveBridge(); RowUpdator::commitTransaction(); } catch (\Exception $ex) { RowUpdator::rollback(); $this->handleException($e); return false; } return true; }