/** * Updates model to database * * @param string * @param Eden_Sql_Database * @param string|null|array * @return this */ public function update($table = NULL, Eden_Sql_Database $database = NULL, $primary = NULL) { User_Error::i()->argument(1, 'string', 'null')->argument(3, 'string', 'null', 'array'); $row = $this->_database->getRow('user', 'user_id', $this->_data['user_id']); if (!$this->validSlug($this->_data['user_slug'])) { User_Error::i()->setMessage(User_Error::INVALID_SLUG)->addVariable($this->_data['user_slug'])->trigger(); } $this->_data['user_updated'] = date('Y-m-d H:i:s'); if ($this->_data['user_parent'] != $row['user_parent']) { $this->_updateLeftRight($userId, $this->_data['user_parent']); } parent::update($table, $database, $primary); $this->_setRelations()->_setAttributes(); return $this; }
/** * Updates model to database * * @param string * @param Eden_Sql_Database * @param string|null|array * @return this */ public function update($table = NULL, Eden_Sql_Database $database = NULL, $primary = NULL) { jobpost_Error::i()->argument(1, 'string', 'null')->argument(3, 'string', 'null', 'array'); //if jobpost user is set and it's a string if (isset($this->_data['jobpost_user']) && is_string($this->_data['jobpost_user'])) { //get the user id and set it $this->_data['jobpost_user'] = $this->_database->getRow('user', 'user_name', $this->_data['jobpost_user']); $this->_data['jobpost_user'] = $this->_data['jobpost_user']['user_id']; } $row = $this->_database->getRow('jobpost', 'jobpost_id', $this->_data['jobpost_id']); if ($this->_data['jobpost_title'] != $row['jobpost_title']) { $this->_data['jobpost_slug'] = $this->_getSlug($this->_data['jobpost_title']); } $this->_data['jobpost_updated'] = date('Y-m-d H:i:s'); if ($this->_data['jobpost_parent'] != $row['jobpost_parent']) { $this->_updateLeftRight($jobpostId, $this->_data['jobpost_parent']); } parent::update($table, $database, $primary); $this->_setRelations()->_setAttributes(); return $this; }