Example #1
0
 private function updateData()
 {
     $tempData = reset($this->modelInstance->getWithField2($this->secondaryKey, $this->modelData[$this->secondaryKey]));
     if ($tempData !== false) {
         if ($this->tertiaryKey != "") {
             $this->modelData[$this->primaryKey] = $tempData[$this->primaryKey];
             $this->modelData[$this->tertiaryKey] = $tempData[$this->tertiaryKey];
         }
         $validated = $this->modelInstance->setData($this->modelData, $this->primaryKey, $tempData[$this->primaryKey]);
         if ($validated === true) {
             $this->modelInstance->update($this->primaryKey, $tempData[$this->primaryKey]);
             $this->updated++;
             return 'Updated';
         } else {
             return $validated;
         }
     } else {
         return $this->addData();
     }
 }