1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
FullText.php
См. документацию.
1<?php
2
4
6use CIBlock;
7
8final class FullText
9{
10 private const INDEX_NAME = 'IBLOCK_ELEMENT_FT_INDEX';
11
12 private static array $existTables = [];
13
14 public static function isTableExist(int $iblockId): bool
15 {
16 if (empty(self::$existTables[$iblockId]))
17 {
19
20 FullText::$existTables[$iblockId] = $connection->isTableExists(FullText::getTableName($iblockId));
21 }
22
23 return FullText::$existTables[$iblockId];
24 }
25
26 public static function isExist(int $iblockId, int $elementId): bool
27 {
29
30 $searchIndexTableName = FullText::getTableName($iblockId);
31
33 {
34 return false;
35 }
36
37 $sqlHelper = $connection->getSqlHelper();
38
39 return !empty(
40 $connection->query(
41 "SELECT ELEMENT_ID FROM "
42 . $sqlHelper->quote($searchIndexTableName)
43 . " WHERE ELEMENT_ID = "
44 . $elementId
45 )->Fetch()
46 );
47 }
48
49 public static function createTable(int $iblockId): void
50 {
52
53 $searchIndexTableName = FullText::getTableName($iblockId);
54
56 {
57 return;
58 }
59
60 $fields = [
61 'ELEMENT_ID' => (new \Bitrix\Main\ORM\Fields\IntegerField('ELEMENT_ID')),
62 'SEARCH_CONTENT' => (new \Bitrix\Main\ORM\Fields\TextField('SEARCH_CONTENT'))->configureNullable(),
63 ];
64
65 $connection->createTable($searchIndexTableName, $fields, ['ELEMENT_ID']);
66 $connection->createIndex($searchIndexTableName, FullText::INDEX_NAME, ['SEARCH_CONTENT'], null, Connection::INDEX_FULLTEXT);
67
68 FullText::$existTables[$iblockId] = true;
69 }
70
71 public static function drop(int $iblockId): void
72 {
74
76 {
77 return;
78 }
79
81
82 FullText::$existTables[$iblockId] = false;
83 }
84
85 public static function add(int $iblockId, array $searchIndexParams): void
86 {
88
89 $searchIndexTableName = FullText::getTableName($iblockId);
90
92 {
94 }
95
96 $connection->add($searchIndexTableName, $searchIndexParams, null);
97 }
98
99 public static function delete(int $iblockId, int $elementId): void
100 {
102
103 $searchIndexTableName = FullText::getTableName($iblockId);
104
106 {
107 return;
108 }
109
110 $sqlHelper = $connection->getSqlHelper();
111
112 $connection->queryExecute("DELETE FROM " . $sqlHelper->quote($searchIndexTableName) . " WHERE ELEMENT_ID = " . $elementId);
113 }
114
115 public static function update(int $iblockId, int $elementId, array $searchIndexParams): void
116 {
118
119 $searchIndexTableName = FullText::getTableName($iblockId);
120
122 {
124 }
125
126 $helper = $connection->getSqlHelper();
127
128 $queries = $helper->prepareMerge(
129 $searchIndexTableName,
130 ['ELEMENT_ID'],
131 array_merge(['ELEMENT_ID' => $elementId], $searchIndexParams),
132 $searchIndexParams,
133 );
134
135 foreach($queries as $query)
136 {
137 $connection->queryExecute($query);
138 }
139 }
140
141 public static function getTableName(int $iblockId): string
142 {
143 return 'b_iblock_' . $iblockId . '_element_search_index';
144 }
145
146 public static function doesIblockSupportById(int $iblockId): bool
147 {
148 return CIBlock::GetArrayByID($iblockId, "FULLTEXT_INDEX") === 'Y';
149 }
150
151 public static function doesIblockSupportByData(array $data): bool
152 {
153 return isset($data['FULLTEXT_INDEX']) && ($data['FULLTEXT_INDEX'] === 'Y');
154 }
155
156 public static function canUseFulltextSearch(int $iblockId): bool
157 {
159 }
160}
$connection
Определения actionsdefinitions.php:38
static createTable(int $iblockId)
Определения FullText.php:49
static add(int $iblockId, array $searchIndexParams)
Определения FullText.php:85
static isExist(int $iblockId, int $elementId)
Определения FullText.php:26
static getTableName(int $iblockId)
Определения FullText.php:141
static doesIblockSupportById(int $iblockId)
Определения FullText.php:146
static doesIblockSupportByData(array $data)
Определения FullText.php:151
static isTableExist(int $iblockId)
Определения FullText.php:14
static drop(int $iblockId)
Определения FullText.php:71
static update(int $iblockId, int $elementId, array $searchIndexParams)
Определения FullText.php:115
static canUseFulltextSearch(int $iblockId)
Определения FullText.php:156
static getConnection($name="")
Определения application.php:638
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11
$iblockId
Определения iblock_catalog_edit.php:30
$fields
Определения yandex_run.php:501