Could you suggest an approach how to implement SELECT FOR UPDATE with Doctrine?
I need to read a counter value, then use it in PHP code and immediately i
Doctrine 2 implements Locking support for entities:
find('User', $theEntityId, LockMode::OPTIMISTIC, $expectedVersion);
// do the work
$em->flush();
} catch(OptimisticLockException $e) {
echo "Someone else has already changed this entity. Apply the changes again!";
}
Also, you can do it throws execute raw SQL:
$em->getConnection()->exec('LOCK TABLES table_name WRITE;'); //lock for write access
and then
$em->getConnection()->exec('UNLOCK TABLES;');