samedi 27 février 2021

"updateOrCreate" method didn't rollback

I use laravel5 then I tried use "updateOrCreat". But it didn't rollback.

Please tell me how to rollback.

I tried following.

Pattern 1 : A data was inserted.

DB::beginTransaction();
Post::updateOrCreate(
    ['id' => '1']
   ,['name' => 'テスト']
);
DB::rollback();

Pettern 2 : A data wasn't inserted

DB::connection('post')->beginTransaction();
Post::updateOrCreate(
    ['id' => '1']
   ,['name' => 'テスト']
);
DB::connection('post')->rollback();

Pettern 3 : A data wasn't inserted

DB::connection('post')->beginTransaction();
Post::updateOrCreate(
    ['id' => '1']
   ,['name' => 'テスト']
);
DB::connection('post')->commit();

Pettern 4 : A data wasn't inserted

DB::beginTransaction(function() {;
    Post::updateOrCreate(
        ['id' => '1']
       ,['name' => 'テスト']
    );
});


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3uBafyg
via IFTTT

Aucun commentaire:

Enregistrer un commentaire