I've been searching on the internet for a method to deal with concurrence in Laravel 4, like for example when you have to block the entire table or just a row for updating or creating but found little information. On the laravel website they mentioned two methods:
lockForUpdate()
sharedLock()
But when I use them, it has no effects. The way I'm using it is as follows:
Check if something exist on the table
Model::queryFunction()->lockForUpdate()->first();
If not exist, create a new item
$new_item = new Model;
$new_item->save();
Else, do nothing
If two users do the same action at the same time, two items are created, and that's not right. I hope you guys can answer my question.