1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Util; |
4
|
|
|
|
5
|
|
|
class DeadlockCodes |
6
|
|
|
{ |
7
|
|
|
private static $POSTGRES; |
8
|
|
|
private static $MARIADB_MYSQL; |
9
|
|
|
private static $MSSQL; |
10
|
|
|
private static $DB2; |
11
|
|
|
private static $ORACLE; |
12
|
|
|
|
13
|
|
|
private $errorCode; |
14
|
|
|
private $sqlState; |
15
|
|
|
|
16
|
|
|
public static function postgres(): DeadlockCodes |
17
|
|
|
{ |
18
|
|
|
if (self::$POSTGRES === null) { |
19
|
|
|
self::$POSTGRES = new DeadlockCodes(0, "40P01"); |
20
|
|
|
} |
21
|
|
|
return self::$POSTGRES; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public static function mariadbMysql(): DeadlockCodes |
25
|
|
|
{ |
26
|
|
|
if (self::$MARIADB_MYSQL === null) { |
27
|
|
|
self::$MARIADB_MYSQL = new DeadlockCodes(1213, "40001"); |
28
|
|
|
} |
29
|
|
|
return self::$MARIADB_MYSQL; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public static function mssql(): DeadlockCodes |
33
|
|
|
{ |
34
|
|
|
if (self::$MSSQL === null) { |
35
|
|
|
self::$MSSQL = new DeadlockCodes(1205, "40001"); |
36
|
|
|
} |
37
|
|
|
return self::$MSSQL; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public static function db2(): DeadlockCodes |
41
|
|
|
{ |
42
|
|
|
if (self::$DB2 === null) { |
43
|
|
|
self::$DB2 = new DeadlockCodes(-911, "40001"); |
44
|
|
|
} |
45
|
|
|
return self::$DB2; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public static function oracle(): DeadlockCodes |
49
|
|
|
{ |
50
|
|
|
if (self::$ORACLE === null) { |
51
|
|
|
self::$ORACLE = new DeadlockCodes(60, "61000"); |
52
|
|
|
} |
53
|
|
|
return self::$ORACLE; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
private function __construct(int $errorCode, ?string $sqlState) |
57
|
|
|
{ |
58
|
|
|
$this->errorCode = $errorCode; |
59
|
|
|
$this->sqlState = $sqlState; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function equals(int $errorCode, ?string $sqlState): bool |
63
|
|
|
{ |
64
|
|
|
return $this->errorCode == $errorCode && $this->sqlState == $sqlState; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|