Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
calluser.php
1<?php
2
3namespace Bitrix\Im\Model;
4
8
25class CallUserTable extends Entity\DataManager
26{
27 public static function getTableName()
28 {
29 return 'b_im_call_user';
30 }
31
32 public static function getMap()
33 {
34 return [
35 new Entity\IntegerField('CALL_ID', [
36 'primary' => true
37 ]),
38 new Entity\IntegerField('USER_ID', [
39 'primary' => true
40 ]),
41 new Entity\StringField('STATE'),
42 new Entity\DatetimeField('FIRST_JOINED'),
43 new Entity\DatetimeField('LAST_SEEN'),
44 new Entity\BooleanField('IS_MOBILE', [
45 'values' => ['N', 'Y']
46 ]),
47 new Entity\BooleanField('SHARED_SCREEN', [
48 'values' => ['N', 'Y']
49 ]),
50 new Entity\BooleanField('RECORDED', [
51 'values' => ['N', 'Y']
52 ]),
53 ];
54 }
55
62 public static function merge(array $data)
63 {
64 $result = new Entity\AddResult();
65
66 $helper = Application::getConnection()->getSqlHelper();
67 $insertData = $data;
68 $updateData = $data;
69 $mergeFields = static::getMergeFields();
70 foreach ($mergeFields as $field)
71 {
72 unset($updateData[$field]);
73 }
74 $merge = $helper->prepareMerge(
75 static::getTableName(),
76 static::getMergeFields(),
77 $insertData,
78 $updateData
79 );
80
81 if ($merge[0] != "")
82 {
83 Application::getConnection()->query($merge[0]);
84 $id = Application::getConnection()->getInsertedId();
85 $result->setId($id);
86 $result->setData($data);
87 }
88 else
89 {
90 $result->addError(new Error('Error constructing query'));
91 }
92
93 return $result;
94 }
95
100 protected static function getMergeFields()
101 {
102 return array('CALL_ID', 'USER_ID');
103 }
104}
static merge(array $data)
Definition calluser.php:62
static getConnection($name="")