Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
workgrouptag.php
1
<?php
8
namespace
Bitrix\Socialnetwork
;
9
10
use
Bitrix\Main\Entity
;
11
use
Bitrix\Main\DB\SqlQueryException
;
12
29
class
WorkgroupTagTable
extends
Entity\DataManager
30
{
31
public
static
function
getTableName
()
32
{
33
return
'b_sonet_group_tag'
;
34
}
35
36
public
static
function
getMap
()
37
{
38
return
array(
39
'GROUP_ID'
=> array(
40
'data_type'
=>
'integer'
,
41
'primary'
=>
true
42
),
43
'GROUP'
=> array(
44
'data_type'
=>
'\Bitrix\Socialnetwork\Workgroup'
,
45
'reference'
=> array(
'=this.GROUP_ID'
=>
'ref.ID'
)
46
),
47
'NAME'
=> array(
48
'data_type'
=>
'string'
,
49
'primary'
=>
true
50
)
51
);
52
}
53
54
public
static
function
deleteByGroupId
($params = array())
55
{
56
if
(
57
!is_array($params)
58
|| empty($params[
'groupId'
])
59
|| intval($params[
'groupId'
]) <= 0
60
)
61
{
62
return
false
;
63
}
64
65
\Bitrix\Main\Application::getConnection()->queryExecute(
'DELETE FROM '
.self::getTableName().
' WHERE GROUP_ID = '
.intval($params[
'groupId'
]));
66
return
true
;
67
}
68
69
public
static
function
set
($params = array())
70
{
71
if
(
72
!is_array($params)
73
|| empty($params[
'groupId'
])
74
|| intval($params[
'groupId'
]) <= 0
75
|| !isset($params[
'tags'
])
76
|| !is_array($params[
'tags'
])
77
)
78
{
79
return
false
;
80
}
81
82
self::deleteByGroupId
(array(
83
'groupId'
=> intval($params[
'groupId'
])
84
));
85
86
foreach
($params[
'tags'
] as $tag)
87
{
88
self::processAdd
(array(
89
'GROUP_ID'
=> intval($params[
'groupId'
]),
90
'NAME'
=> toLower($tag)
91
));
92
}
93
94
return
true
;
95
}
96
97
protected
static
function
processAdd
(array $data)
98
{
99
try
100
{
101
self::add($data);
102
}
103
catch
(
SqlQueryException
$exception)
104
{
105
if
(!self::isDuplicateKeyError($exception))
106
{
107
throw
$exception;
108
}
109
}
110
}
111
112
protected
static
function
isDuplicateKeyError
(
SqlQueryException
$exception)
113
{
114
return
mb_strpos($exception->
getDatabaseMessage
(),
'(1062)'
) !==
false
;
115
}
116
}
Bitrix\Main\DB\Exception\getDatabaseMessage
getDatabaseMessage()
Definition
exception.php:37
Bitrix\Main\DB\SqlQueryException
Definition
sqlexception.php:24
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Socialnetwork\WorkgroupTagTable
Definition
workgrouptag.php:30
Bitrix\Socialnetwork\WorkgroupTagTable\processAdd
static processAdd(array $data)
Definition
workgrouptag.php:97
Bitrix\Socialnetwork\WorkgroupTagTable\getMap
static getMap()
Definition
workgrouptag.php:36
Bitrix\Socialnetwork\WorkgroupTagTable\deleteByGroupId
static deleteByGroupId($params=array())
Definition
workgrouptag.php:54
Bitrix\Socialnetwork\WorkgroupTagTable\isDuplicateKeyError
static isDuplicateKeyError(SqlQueryException $exception)
Definition
workgrouptag.php:112
Bitrix\Socialnetwork\WorkgroupTagTable\getTableName
static getTableName()
Definition
workgrouptag.php:31
Bitrix\Socialnetwork
modules
socialnetwork
lib
workgrouptag.php
Создано системой
1.10.0