summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Utility/LockSqlHelper.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/orm/src/Utility/LockSqlHelper.php')
-rw-r--r--vendor/doctrine/orm/src/Utility/LockSqlHelper.php35
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
3declare(strict_types=1);
4
5namespace Doctrine\ORM\Utility;
6
7use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
8use Doctrine\DBAL\Platforms\AbstractPlatform;
9use Doctrine\DBAL\Platforms\DB2Platform;
10use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
11use Doctrine\DBAL\Platforms\SQLitePlatform;
12use Doctrine\DBAL\Platforms\SQLServerPlatform;
13
14/** @internal */
15trait 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}