Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
call.php
1<?php
2
3namespace Bitrix\Im\Model;
4
5use Bitrix\Disk\Internals\Entity\Query;
11
28class CallTable extends Entity\DataManager
29{
30 public static function getTableName()
31 {
32 return 'b_im_call';
33 }
34
35 public static function getMap()
36 {
37 return array(
38 new Entity\IntegerField('ID', array(
39 'primary' => true,
40 'autocomplete' => true
41 )),
42 new Entity\IntegerField('TYPE'),
43 new Entity\IntegerField('INITIATOR_ID'),
44 new Entity\StringField('IS_PUBLIC', array(
45 'default_value' => 'N'
46 )),
47 new Entity\StringField('PUBLIC_ID'),
48 new Entity\StringField('PROVIDER'),
49 new Entity\StringField('ENTITY_TYPE'),
50 new Entity\StringField('ENTITY_ID'),
51 new Entity\IntegerField('PARENT_ID'),
52 new Entity\StringField('STATE'),
53 new Entity\DatetimeField('START_DATE', array(
54 'default_value' => function()
55 {
56 return new DateTime();
57 }
58 )),
59 new Entity\DatetimeField('END_DATE'),
60 new Entity\IntegerField('CHAT_ID'),
61 new Entity\StringField('LOG_URL'),
62 new Entity\StringField(
63 'UUID',
64 [
65 'size' => 36,
66 ]
67 ),
68 new Entity\StringField(
69 'SECRET_KEY',
70 [
71 'size' => 10,
72 ]
73 ),
74 new Entity\StringField(
75 'ENDPOINT'
76 ),
77 );
78 }
79
86 public static function updateState(int $id, string $newState) : bool
87 {
88 $connection = Application::getConnection();
89 $sqlHelper = $connection->getSqlHelper();
90 $tableName = static::getTableName();
91 $newState = $sqlHelper->forSql($newState);
92
93 $update = "STATE = '$newState'";
94 if($newState === Call::STATE_FINISHED)
95 {
96 $update .= ", END_DATE = CURRENT_TIMESTAMP";
97 }
98
99 $query = "
100 UPDATE
101 $tableName
102 SET
103 $update
104 WHERE
105 ID = $id
106 AND STATE != '$newState'
107 ";
108
109 $connection->query($query);
110 return $connection->getAffectedRowsCount() === 1;
111 }
112
113}
static updateState(int $id, string $newState)
Definition call.php:86
static getConnection($name="")