I have an app where I'm using Elloquent working with transactions and I need to retrieve the new objects after calling the commit method, however, the commit is fired near the end of the request.
Here is an example of my problem, I didn't post the original code, I just want to illustrate what I am facing
<?php
DB::beginTransaction();
try{
$u= \App\User::count(); //returns x
$u_new= new \App\User(['name' => 'John']);
$u_new->save();
DB::commit();
}catch(\PDOException $e){
DB::rollback();
}
$u2= \App\User::count(); //keeps returning x and not x+1
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/deIFCVm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire