76 public static function set($params = []): bool
79 $itemId = (int)($params[
'itemId'] ?? 0);
80 $logId = (int)($params[
'logId'] ?? 0);
81 $content = trim(($params[
'content'] ??
''));
84 !in_array($itemType, self::getItemTypes())
94 $helper = $connection->getSqlHelper();
96 $value = $helper->forSql($content);
97 $encryptedValue = sha1($content);
100 'ITEM_TYPE' => $helper->forSql($itemType),
101 'ITEM_ID' => $itemId,
107 'CONTENT' =>
new SqlExpression(
"IF(SHA1(CONTENT) = '{$encryptedValue}', CONTENT, '{$value}')"),
111 isset($params[
'logDateUpdate'])
112 && $params[
'logDateUpdate'] instanceof
DateTime
115 $insertFields[
'LOG_UPDATE'] = $params[
'logDateUpdate'];
116 $updateFields[
'LOG_UPDATE'] = $params[
'logDateUpdate'];
120 isset($params[
'dateCreate'])
121 && $params[
'dateCreate'] instanceof
DateTime
124 $insertFields[
'DATE_CREATE'] = $params[
'dateCreate'];
125 $updateFields[
'DATE_CREATE'] = $params[
'dateCreate'];
128 $merge = $helper->prepareMerge(
129 static::getTableName(),
130 [
'ITEM_TYPE',
'ITEM_ID' ],
137 $connection->query($merge[0]);
145 $logId = (int)($params[
'logId'] ?? 0);
146 $value = (!empty($params[
'value']) ? $params[
'value'] :
false);
154 $helper = $connection->getSqlHelper();
156 $now = $connection->getSqlHelper()->getCurrentDateTimeFunction();
159 || mb_strtolower($value) == mb_strtolower($now)
166 "LOG_UPDATE" => $value,
170 list($prefix, $values) = $helper->prepareUpdate($tableName, $updateFields);
171 $connection->queryExecute(
"UPDATE {$tableName} SET {$prefix} WHERE LOG_ID = " . $logId);