예제 #1
0
파일: PerfORM.php 프로젝트: Edke/PerfORM
 /**
  * Saving model
  *
  * When primary key is set, model will be updated otherwise inserted
  * @return mixed model's primary key value
  */
 public function save()
 {
     if ($this->isView()) {
         throw new Exception('Unable to save view.');
     }
     $pk = $this->getPrimaryKey();
     // has primary key set, record exists -> updating
     if ($this->fields[$pk]->getValue()) {
         if ($this->isExtended()) {
             $this->extends->save();
         }
         return $this->update();
     } else {
         if ($this->isExtended()) {
             $this->{$pk} = $this->extends->save();
         }
         return $this->insert();
     }
 }