1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Datawriter postSave & setAfterPreSave

Discussion in 'XenForo Development Discussions' started by ragtek, Jun 20, 2011.

  1. ragtek

    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 )
     
  2. Mike

    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.
     
  3. ragtek

    ragtek Guest

    Ahh, i see.
    thx:)
     

Share This Page