Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messageunread.php
1<?php
2namespace Bitrix\Im\Model;
3
5use Bitrix\Im\V2\Common\InsertSelectTrait;
6use Bitrix\Im\V2\Common\MultiplyInsertTrait;
9use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
10use Bitrix\Main\ORM\Data\Internal\MergeTrait;
16
47{
48 use DeleteByFilterTrait;
49 use MergeTrait;
50 use InsertSelectTrait;
51 use MultiplyInsertTrait;
52
58 public static function getTableName()
59 {
60 return 'b_im_message_unread';
61 }
62
68 public static function getMap()
69 {
70 return [
71 'ID' => new IntegerField(
72 'ID',
73 [
74 'primary' => true,
75 'autocomplete' => true,
76 ]
77 ),
78 'USER_ID' => new IntegerField(
79 'USER_ID',
80 [
81 'required' => true,
82 ]
83 ),
84 'CHAT_ID' => new IntegerField(
85 'CHAT_ID',
86 [
87 'required' => true,
88 ]
89 ),
90 'MESSAGE_ID' => new IntegerField(
91 'MESSAGE_ID',
92 [
93 'required' => true,
94 ]
95 ),
96 'IS_MUTED' => new BooleanField(
97 'IS_MUTED',
98 [
99 'required' => true,
100 'values' => array('N', 'Y'),
101 ]
102 ),
103 'CHAT_TYPE' => new StringField(
104 'CHAT_TYPE',
105 [
106 'required' => true,
107 ]
108 ),
109 'DATE_CREATE' => new DatetimeField(
110 'DATE_CREATE',
111 [
112 'default' => function()
113 {
114 return new DateTime();
115 },
116 ]
117 ),
118 ];
119 }
120
121 public static function updateBatch(array $fields, array $filter): void
122 {
123 $tableName = static::getTableName();
124 $connection = Application::getConnection();
125 $sqlHelper = $connection->getSqlHelper();
126
127 $update = $sqlHelper->prepareUpdate($tableName, $fields);
128
129 $query = new Query(static::getEntity());
130 $query->setFilter($filter);
131 $query->getQuery();
132
133 $alias = $sqlHelper->quote($query->getInitAlias()) . '.';
134 $where = str_replace($alias, '', $query->getWhere());
135
136 $sql = 'UPDATE ' . $tableName . ' SET ' . $update[0] . ' WHERE ' . $where;
137 $connection->queryExecute($sql, $update[1]);
138 }
139}
static updateBatch(array $fields, array $filter)
static getConnection($name="")