Datawriter postSave & setAfterPreSave

R

ragtek

Guest
Why do we need to set the value in the datamanager if it's not saving the value and we need to run a extra query?

For example

PHP:
        if ($rows)
        {
            // TODO: ideally, this can be consolidated with other post-save message updates (see updateIpData)
            $this->set('attach_count', $this->get('attach_count') + $rows, '', array('setAfterPreSave' => true));

            $this->_db->update($this->getDiscussionMessageTableName(), array(
                'attach_count' => $this->get('attach_count')
            ), $this->getDiscussionMessageKeyName() . ' = ' .  $this->_db->quote($this->getDiscussionMessageId()));
        }
Shouldn't this save the value without the need to run the db update? (it doesn't do this, but i don't understand why:D )
 

Mike

XenForo developer
Staff member
In post save, the record has already been saved, so it has to be updated manually. The value is set into the local DW field to ensure that it reflects the record accurately for other PHP code.
 
Top