Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
commandtrait.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Processor
;
4
5
6
use
Bitrix\Main\Application
;
7
use
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterDictionary
;
8
use
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterTable
;
9
10
trait CommandTrait
11
{
12
public
static
function
reset(
int
$userId = 0, array $types = [], array $logIds = [], array $groupIds = [], array $exceptGroups = []): void
13
{
14
$where = [];
15
16
if
($userId)
17
{
18
$where[] =
'USER_ID = '
. $userId;
19
}
20
21
if
(!empty($types))
22
{
23
$where[] =
"TYPE IN ('"
. implode(
"','"
, $types) .
"')"
;
24
}
25
26
if
(!empty($logIds))
27
{
28
$where[] =
"SONET_LOG_ID IN ("
. implode(
","
, $logIds) .
")"
;
29
}
30
31
if
(!empty($groupIds))
32
{
33
$where[] =
"GROUP_ID IN ("
. implode(
","
, $groupIds) .
")"
;
34
}
35
36
if
(!empty($exceptGroups))
37
{
38
$where[] =
"GROUP_ID NOT IN ("
. implode(
","
, $exceptGroups) .
")"
;
39
}
40
41
$where = (!empty($where)) ? (
'WHERE '
. implode(
' AND '
, $where)) :
''
;
42
43
$sql =
"
44
DELETE
45
FROM "
.
CounterTable::getTableName
().
"
46
{$where}
47
"
;
48
49
Application::getConnection
()->query($sql);
50
}
51
52
private
function
saveFlag(
int
$userId): void
53
{
54
$sql =
"
55
INSERT INTO "
.
CounterTable::getTableName
() .
"
56
(USER_ID, SONET_LOG_ID, GROUP_ID, TYPE, VALUE)
57
VALUES ({$userId}, 0, 0, '"
.
CounterDictionary::COUNTER_FLAG_COUNTED
.
"', 1)
58
"
;
59
Application::getConnection
()->query($sql);
60
}
61
62
private
function
batchInsert(array $data): void
63
{
64
$req = [];
65
foreach
($data as $row)
66
{
67
$row[
'TYPE'
] =
"'"
. $row[
'TYPE'
] .
"'"
;
68
$req[] = implode(
','
, $row);
69
}
70
71
if
(empty($req))
72
{
73
return
;
74
}
75
76
$sql =
"
77
INSERT INTO "
.
CounterTable::getTableName
().
"
78
(USER_ID, SONET_LOG_ID, GROUP_ID, TYPE, VALUE)
79
VALUES
80
("
. implode(
"),("
, $req) .
")
81
"
;
82
83
Application::getConnection
()->query($sql);
84
}
85
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getConnection
static getConnection($name="")
Definition
application.php:611
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterDictionary
Definition
counterdictionary.php:8
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterDictionary\COUNTER_FLAG_COUNTED
const COUNTER_FLAG_COUNTED
Definition
counterdictionary.php:28
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterTable
Definition
countertable.php:26
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterTable\getTableName
static getTableName()
Definition
countertable.php:27
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Processor
Definition
commandtrait.php:3
modules
socialnetwork
lib
internals
livefeed
counter
processor
commandtrait.php
Создано системой
1.10.0