1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
dictionary.php
См. документацию.
1
<?php
7
namespace
Bitrix\Iblock\PropertyIndex
;
8
9
class
Dictionary
10
{
11
protected
$iblockId
= 0;
12
protected
$cache
=
array
();
13
protected
static
$exists
=
array
();
14
18
public
function
__construct
(
$iblockId
)
19
{
20
$this->iblockId = intval(
$iblockId
);
21
}
22
28
public
function
getIblockId
()
29
{
30
return
$this->iblockId
;
31
}
32
38
public
function
getTableName
()
39
{
40
return
"b_iblock_"
.$this->iblockId.
"_index_val"
;
41
}
42
49
public
function
isExists
()
50
{
51
if
(!isset(self::$exists[$this->iblockId]))
52
{
53
$connection
=
\Bitrix\Main\Application::getConnection
();
54
self::$exists[
$this->iblockId
] =
$connection
->isTableExists($this->
getTableName
());
55
}
56
57
return
self::$exists[
$this->iblockId
];
58
}
59
66
public
static
function
validateValue
()
67
{
68
return
array
(
69
new
\
Bitrix
\
Main
\
Entity
\
Validator
\Length(
null
, 2000),
70
);
71
}
72
79
public
function
create
()
80
{
81
$connection
=
\Bitrix\Main\Application::getConnection
();
82
83
$connection
->createTable($this->
getTableName
(),
array
(
84
"ID"
=>
new
\
Bitrix
\
Main
\
Entity
\
IntegerField
(
"ID"
,
array
(
85
'primary'
=>
true
,
86
'unique'
=>
true
,
87
'required'
=>
true
,
88
)),
89
"VALUE"
=>
new
\
Bitrix
\
Main
\
Entity
\
StringField
(
"VALUE"
,
array
(
90
'required'
=>
true
,
91
'validation'
=>
array
(__CLASS__,
'validateValue'
),
92
)),
93
),
array
(
"ID"
),
array
(
"ID"
));
94
95
$connection
->createIndex($this->
getTableName
(),
'IX_'
.$this->
getTableName
().
'_0'
,
array
(
"VALUE"
),
array
(
"VALUE"
=> 200));
96
97
$this->cache =
array
();
98
self::$exists[
$this->iblockId
] =
true
;
99
}
100
107
public
function
drop
()
108
{
109
$connection
=
\Bitrix\Main\Application::getConnection
();
110
111
$connection
->dropTable($this->
getTableName
());
112
113
$this->cache =
array
();
114
self::$exists[
$this->iblockId
] =
false
;
115
}
116
125
public
function
getStringId
($value, $addWhenNotFound =
true
)
126
{
127
if
(!isset($this->cache[$value]))
128
{
129
$connection
=
\Bitrix\Main\Application::getConnection
();
130
131
$sqlHelper =
$connection
->getSqlHelper();
132
$valueId =
$connection
->queryScalar(
"SELECT ID FROM "
.$this->
getTableName
().
" WHERE VALUE = '"
.$sqlHelper->forSql($value).
"'"
);
133
if
($valueId ===
null
)
134
{
135
if
($addWhenNotFound)
136
{
137
$valueId =
$connection
->add($this->
getTableName
(),
array
(
138
"VALUE"
=> $value,
139
));
140
}
141
else
142
{
143
$valueId = 0;
144
}
145
}
146
147
$this->cache[$value] = intval($valueId);
148
}
149
150
return
$this->cache[$value];
151
}
152
160
public
function
getStringById
($valueId)
161
{
162
$valueId = (int)$valueId;
163
if
($valueId <= 0)
164
return
""
;
165
166
$connection
=
\Bitrix\Main\Application::getConnection
();
167
$stringValue =
$connection
->queryScalar(
"SELECT VALUE FROM "
.$this->
getTableName
().
" WHERE ID = "
.$valueId);
168
return
($stringValue ===
null
?
""
: $stringValue);
169
}
170
178
public
function
getStringByIds
($valueIDs)
179
{
180
$result
= [];
181
if
(empty($valueIDs) || !is_array($valueIDs))
182
return
$result
;
183
\Bitrix\Main\Type\Collection::normalizeArrayValuesByInt
($valueIDs,
true
);
184
if
(empty($valueIDs))
185
return
$result
;
186
187
$connection
=
\Bitrix\Main\Application::getConnection
();
188
189
$result
= array_fill_keys($valueIDs,
''
);
190
191
$rs
=
$connection
->query(
"SELECT ID, VALUE FROM "
.$this->
getTableName
().
" WHERE ID IN("
.implode(
','
,$valueIDs).
")"
);
192
while
($row =
$rs
->fetch())
193
{
194
$result
[$row[
'ID'
]] = $row[
'VALUE'
];
195
}
196
197
return
$result
;
198
}
199
}
$connection
$connection
Определения
actionsdefinitions.php:38
Bitrix\Iblock\PropertyIndex\Dictionary\__construct
__construct($iblockId)
Определения
dictionary.php:18
Bitrix\Iblock\PropertyIndex\Dictionary\getStringByIds
getStringByIds($valueIDs)
Определения
dictionary.php:178
Bitrix\Iblock\PropertyIndex\Dictionary\$iblockId
$iblockId
Определения
dictionary.php:11
Bitrix\Iblock\PropertyIndex\Dictionary\getIblockId
getIblockId()
Определения
dictionary.php:28
Bitrix\Iblock\PropertyIndex\Dictionary\create
create()
Определения
dictionary.php:79
Bitrix\Iblock\PropertyIndex\Dictionary\getStringId
getStringId($value, $addWhenNotFound=true)
Определения
dictionary.php:125
Bitrix\Iblock\PropertyIndex\Dictionary\validateValue
static validateValue()
Определения
dictionary.php:66
Bitrix\Iblock\PropertyIndex\Dictionary\getStringById
getStringById($valueId)
Определения
dictionary.php:160
Bitrix\Iblock\PropertyIndex\Dictionary\getTableName
getTableName()
Определения
dictionary.php:38
Bitrix\Iblock\PropertyIndex\Dictionary\$exists
static $exists
Определения
dictionary.php:13
Bitrix\Iblock\PropertyIndex\Dictionary\$cache
$cache
Определения
dictionary.php:12
Bitrix\Iblock\PropertyIndex\Dictionary\drop
drop()
Определения
dictionary.php:107
Bitrix\Iblock\PropertyIndex\Dictionary\isExists
isExists()
Определения
dictionary.php:49
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Определения
stringfield.php:20
Bitrix\Main\ORM\Fields\Validators\Validator
Определения
validator.php:18
Bitrix\Main\Type\Collection\normalizeArrayValuesByInt
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения
collection.php:150
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$iblockId
$iblockId
Определения
iblock_catalog_edit.php:30
Bitrix\Iblock\PropertyIndex
Определения
dictionary.php:7
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main
Bitrix\Rest\Dictionary
Определения
booklet.php:9
Bitrix
$rs
$rs
Определения
action.php:82
bitrix
modules
iblock
lib
propertyindex
dictionary.php
Создано системой
1.14.0