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

Can I do this with the datawriter?

Discussion in 'XenForo Development Discussions' started by Jaxel, Mar 30, 2011.

  1. Jaxel

    Jaxel Well-Known Member

    Code:
    $dw = XenForo_DataWriter::create('EWRcarta_DataWriter_Pages');
    $dw->setExistingData($input);
    
    $dw->bulkSet(array(
        'page_name'    => $input['page_name'],
        'page_slug' => $input['page_slug'],
        'page_type' => $input['page_type'],
        'page_content' => $input['page_content'],
        'page_parent' => $input['page_parent'],
        'page_index' => $input['page_index'],
        'page_protect' => $input['page_protect'],
        'page_sidebar' => $input['page_sidebar'],
        'page_sublist' => $input['page_sublist']
    ));
    $dw->save();
    $input['page_id'] = $dw->get('page_id');
    $input['page_date'] = $dw->get('page_date');
    
    if (DATA 'page_content' WAS CHANGED)
    {
        $this->getModelFromCache('EWRcarta_Model_History')->updateHistory($input);
    }
    Basically, I only want to run the updateHistory function if 'page_content' was recently changed. Is this possible?
     
  2. Jaxel

    Jaxel Well-Known Member

    Figured it out...
    Code:
    if ($dw->isChanged('page_content'))
     
  3. ragtek

    ragtek Guest

    Yes

    PHP:
    if ($this->isUpdate() && $this->isChanged('FIELD'))
    edit:
    ok you was faster^^
     

Share This Page