public function save(Model $model)
    {
        $model->validate();

        if ($model->exists()) {
            if ($model->isModified()) {
                $this->connection
                    ->update($this->dummy->getTableName())
                    ->where($model::getIdField(), '=', $model->getId())
                    ->set($model->getSaveableProperties())
                    ->execute();
            }
        } else {
            $this->connection
                ->insert($model->getSaveableProperties())
                ->into($this->dummy->getTableName())
                ->execute();

            $model->setId($this->connection->getPdo()->lastInsertId());
        }
    }
public function save(Model $model)
    {
        $model->validate();

        if ($model->exists()) {
            if ($model->isModified()) {
                $this->connection
                    ->update($this->dummy->getTableName())
                    ->where($model::getIdField(), '=', $model->getId())
                    ->set($model->getSaveableProperties())
                    ->execute();
            }
        } else {
            $this->connection
                ->insert($model->getSaveableProperties())
                ->into($this->dummy->getTableName())
                ->execute();

            $model->setId($this->connection->getPdo()->lastInsertId());
        }
    }
public function save ( Model $ model ) { $ model -> validate ( ) ; if ( $ model -> exists ( ) ) { if ( $ model -> isModified ( ) ) { $ this -> connection -> update ( $ this -> dummy -> getTableName ( ) ) -> where ( $ model :: getIdField ( ) , '=' , $ model -> getId ( ) ) -> set ( $ model -> getSaveableProperties ( ) ) -> execute ( ) ; } } else { $ this -> connection -> insert ( $ model -> getSaveableProperties ( ) ) -> into ( $ this -> dummy -> getTableName ( ) ) -> execute ( ) ; $ model -> setId ( $ this -> connection -> getPdo ( ) -> lastInsertId ( ) ) ; } }
Save the model into the database

@param Model $model

@return void
@throws \OlajosCs\Repository\Exceptions\ValidationException
Save the model into the database