Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
locker.php
1<?
3
6
7class Locker
8{
9 const CONNECTION_NAME = "composite";
10
18 public static function lock($id)
19 {
20 $result = true;
21 $connection = static::getConnection();
22 if ($connection instanceof MysqlCommonConnection)
23 {
24 $result = $connection->lock($id);
25 }
26
27 return $result;
28 }
29
37 public static function unlock($id)
38 {
39 $connection = static::getConnection();
40 if ($connection instanceof MysqlCommonConnection)
41 {
42 $connection->unlock($id);
43 }
44
45 return true;
46 }
47
52 private static function getConnection()
53 {
54 $pool = Application::getInstance()->getConnectionPool();
55 $connection = $pool->getConnection(static::CONNECTION_NAME);
56 if (!$connection)
57 {
58 $connection = $pool->cloneConnection(
59 $pool::DEFAULT_CONNECTION_NAME,
60 static::CONNECTION_NAME
61 );
62 }
63
64 return $connection;
65 }
66
67}