/** * {@inheritdoc} */ public function save() { /// A read-only row cannot be saved. if ($this->_readOnly === true) { throw new Exception('ERR.READ_ONLY'); } /// Allows pre-save logic to be applied to any row. /// Zend_Db_Table_Row only uses to do it on _insert OR _update, /// why Zend, why? /// /// Computers are bullshit! $this->_save(); foreach ($this->_data as $column => &$value) { if ($value instanceof \DateTime) { $value->setFormat('Y:m:d H:i:s'); } } if (false !== $this->getErrors()) { throw new Exception('ERR.VALIDATION_INVALID'); } $user = Table::getAuthUser(); if ($user) { $created_by = $user->id; } else { $created_by = 1; } if ($this->isNewRecord()) { if ($this->offsetExists('created_by')) { $this->created_by = $created_by; } if ($this->offsetExists('updated_by')) { $this->updated_by = $created_by; } } else { if ($this->offsetExists('updated_by')) { $this->updated_by = $created_by; } } /// parent::save(); /// $this->_postSave(); }