diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Utility/LockSqlHelper.php')
| -rw-r--r-- | vendor/doctrine/orm/src/Utility/LockSqlHelper.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Utility/LockSqlHelper.php b/vendor/doctrine/orm/src/Utility/LockSqlHelper.php new file mode 100644 index 0000000..7d135eb --- /dev/null +++ b/vendor/doctrine/orm/src/Utility/LockSqlHelper.php | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM\Utility; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; | ||
| 8 | use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
| 9 | use Doctrine\DBAL\Platforms\DB2Platform; | ||
| 10 | use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
| 11 | use Doctrine\DBAL\Platforms\SQLitePlatform; | ||
| 12 | use Doctrine\DBAL\Platforms\SQLServerPlatform; | ||
| 13 | |||
| 14 | /** @internal */ | ||
| 15 | trait LockSqlHelper | ||
| 16 | { | ||
| 17 | private function getReadLockSQL(AbstractPlatform $platform): string | ||
| 18 | { | ||
| 19 | return match (true) { | ||
| 20 | $platform instanceof AbstractMySQLPlatform => 'LOCK IN SHARE MODE', | ||
| 21 | $platform instanceof PostgreSQLPlatform => 'FOR SHARE', | ||
| 22 | default => $this->getWriteLockSQL($platform), | ||
| 23 | }; | ||
| 24 | } | ||
| 25 | |||
| 26 | private function getWriteLockSQL(AbstractPlatform $platform): string | ||
| 27 | { | ||
| 28 | return match (true) { | ||
| 29 | $platform instanceof DB2Platform => 'WITH RR USE AND KEEP UPDATE LOCKS', | ||
| 30 | $platform instanceof SQLitePlatform, | ||
| 31 | $platform instanceof SQLServerPlatform => '', | ||
| 32 | default => 'FOR UPDATE', | ||
| 33 | }; | ||
| 34 | } | ||
| 35 | } | ||
