Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messageindex.php
1<?php
2namespace Bitrix\Im\Model;
3
8
9
35class MessageIndexTable extends Main\Entity\DataManager
36{
42 public static function getTableName()
43 {
44 return 'b_im_message_index';
45 }
46
52 public static function getMap()
53 {
54 return array(
55 'MESSAGE_ID' => array(
56 'data_type' => 'integer',
57 'primary' => true,
58 ),
59 'SEARCH_CONTENT' => array(
60 'data_type' => 'text',
61 ),
62 );
63 }
64
65 public static function validateTitle()
66 {
67 return array(
68 new Entity\Validator\Length(null, 255),
69 );
70 }
71
72 protected static function getMergeFields()
73 {
74 return array('MESSAGE_ID');
75 }
76
77 public static function merge(array $data)
78 {
79 $result = new Entity\AddResult();
80
81 $helper = Application::getConnection()->getSqlHelper();
82 $insertData = $data;
83 $updateData = $data;
84 $mergeFields = static::getMergeFields();
85
86 foreach ($mergeFields as $field)
87 {
88 unset($updateData[$field]);
89 }
90
91 $merge = $helper->prepareMerge(
92 static::getTableName(),
93 static::getMergeFields(),
94 $insertData,
95 $updateData
96 );
97
98 if ($merge[0] != "")
99 {
100 Application::getConnection()->query($merge[0]);
101 $id = Application::getConnection()->getInsertedId();
102 $result->setId($id);
103 $result->setData($data);
104 }
105 else
106 {
107 $result->addError(new Error('Error constructing query'));
108 }
109
110 return $result;
111 }
112}
static getConnection($name="")