Transaction with Laravel

Asked

Viewed 122 times

0

DB::connection('gtsql')->beginTransaction();
$seriefat = DB::connection('gtsql')->table('se_seriefat')
                                   ->where('c_codserie', 'FO')->first();

echo $seriefat->c_numultdoc;

sleep(15);

DB::connection('gtsql')->commit();

If Run in this 15-second time an update to this table record se_seriefat... it works normal should not return me a lock error?

I am using SQLSRV

  • In that code there is no update !!!

  • So, but it only works if I give it a $seriefat->save() ? Sure it wouldn’t stay in lock, locked the record until I give commit() ?

  • idea if this doesn’t work.. $seriefat = SerieFat::where('c_codserie','FO')->first();


 $seriefat->c_numultdoc = $seriefat->c_numultdoc + 1;
 if ($seriefat->save()) {
 echo 'Atualizaou';
 } else {
 echo 'Não Atualizou';
 }

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.