Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
logpinned.php
1<?php
9
10use Bitrix\Main;
14
15Loc::loadMessages(__FILE__);
16
33class LogPinnedTable extends Entity\DataManager
34{
35 public static function getTableName()
36 {
37 return 'b_sonet_log_pinned';
38 }
39
40 public static function getMap()
41 {
42 $fieldsMap = [
43 'LOG_ID' => [
44 'data_type' => 'integer',
45 'primary' => true
46 ],
47 'USER_ID' => [
48 'data_type' => 'integer',
49 'primary' => true
50 ],
51 'PINNED_DATE' => [
52 'data_type' => 'datetime',
53 ],
54 ];
55
56 return $fieldsMap;
57 }
58
59
60 public static function set(array $params = [])
61 {
62 global $USER;
63
64 $logId = (isset($params['logId']) ? intval($params['logId']) : 0);
65 $userId = (isset($params['userId']) ? intval($params['userId']) : (is_object($USER) && $USER instanceof \CUser ? $USER->getId() : 0));
66
67 if ($logId <= 0)
68 {
69 throw new Main\SystemException("Empty logId.");
70 }
71
72 if ($userId <= 0)
73 {
74 throw new Main\SystemException("Empty userId.");
75 }
76
77 $connection = \Bitrix\Main\Application::getConnection();
78 $helper = $connection->getSqlHelper();
79
80 $insertFields = [
81 'LOG_ID' => $logId,
82 'USER_ID' => $userId,
83 'PINNED_DATE' => new \Bitrix\Main\DB\SqlExpression($helper->getCurrentDateTimeFunction()),
84 ];
85
86 $updateFields = [
87 'PINNED_DATE' => new \Bitrix\Main\DB\SqlExpression($helper->getCurrentDateTimeFunction()),
88 ];
89
90 $merge = $helper->prepareMerge(
91 static::getTableName(),
92 [ 'LOG_ID', 'USER_ID' ],
93 $insertFields,
94 $updateFields
95 );
96
97 if ($merge[0] != "")
98 {
99 $connection->query($merge[0]);
100 }
101 }
102
103 public static function add(array $data)
104 {
105 throw new NotImplementedException("Use set() method of the class.");
106 }
107
108 public static function update($primary, array $data)
109 {
110 throw new NotImplementedException("Use set() method of the class.");
111 }
112}
static loadMessages($file)
Definition loc.php:64
static update($primary, array $data)