lockForUpdate()
$model = \App\Models\User::lockForUpdate()->find(1);
https://stackoverflow.com/questions/34556511/laravel-lockforupdate-pessimistic-locking
Transaction
https://laracasts.com/discuss/channels/general-discussion/how-properly-use-the-lockforupdate-method
use Illuminate\Support\Facades\DB;
https://stackoverflow.com/questions/49814785/how-can-i-use-transaction-with-eloquent-laravel-5-5
DB::beginTransaction();
try {
$project = Project::find($id);
$project->users()->detach();
$project->delete();
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
return response()->json(['error' => $ex->getMessage()], 500);
}
https://stackoverflow.com/questions/16846531/how-to-read-fetchpdofetch-assoc
PDOStatement::fetch returns a row from the result set. The parameter PDO::FETCH_ASSOC
tells PDO to return the result as an associative array.
No comments:
Post a Comment