update() public static method

Update an existing item.
Deprecation: use doctrine instead
public static update ( array $item ) : integer
$item array The new data.
return integer
Example #1
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         $fields = $this->frm->getFields();
         // validate fields
         $fields['title']->isFilled(BL::err('TitleIsRequired'));
         if ($this->frm->isCorrect()) {
             $item['id'] = $this->id;
             $item['user_id'] = BackendAuthentication::getUser()->getUserId();
             $item['template'] = count($this->templates) > 1 ? $fields['template']->getValue() : $this->templates[0];
             $item['language'] = $this->record['language'];
             $item['extra_id'] = $this->record['extra_id'];
             $item['title'] = $fields['title']->getValue();
             $item['text'] = $fields['text']->getValue();
             $item['hidden'] = $fields['hidden']->getChecked() ? 'N' : 'Y';
             $item['status'] = 'active';
             $item['created_on'] = BackendModel::getUTCDate(null, $this->record['created_on']);
             $item['edited_on'] = BackendModel::getUTCDate();
             // insert the item
             $item['revision_id'] = BackendContentBlocksModel::update($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=edited&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }