Now i'm using Laravel 4 for website development , when i'll edit record by this query
$cc=DB::table('customers')->where('transaction_id', '=', $_GET['edit'])->lockForUpdate()->get();
But when i login by another session from another browser the user can show record as i do query on page that select for update Now i want every user lock record that edit it any help and thank you .
Lock for update will only work inside a transaction. Something like the following should work:
DB::transaction(function() {
$cc = DB::table('customers')->where('transaction_id', '=', $_GET['edit'])->lockForUpdate()->get();
...
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.