92 public static function merge(array $data)
96 $result =
new Entity\AddResult();
101 $mergeFields = static::getMergeFields();
103 foreach ($mergeFields as $field)
105 unset($updateData[$field]);
108 if (isset($updateData[
'SEARCH_USER_CONTENT']))
110 $value = $DB->forSql($updateData[
'SEARCH_USER_CONTENT']);
111 $encryptedValue = sha1($updateData[
'SEARCH_USER_CONTENT']);
112 $updateData[
'SEARCH_USER_CONTENT'] = new \Bitrix\Main\DB\SqlExpression(
"case when " . $helper->getSha1Function(static::getTableName().
".SEARCH_USER_CONTENT") .
" = '{$encryptedValue}' then ".static::getTableName().
".SEARCH_USER_CONTENT else '{$value}' end");
115 if (isset($updateData[
'SEARCH_DEPARTMENT_CONTENT']))
117 $value = $DB->forSql($updateData[
'SEARCH_DEPARTMENT_CONTENT']);
118 $encryptedValue = sha1($updateData[
'SEARCH_DEPARTMENT_CONTENT']);
119 $updateData[
'SEARCH_DEPARTMENT_CONTENT'] = new \Bitrix\Main\DB\SqlExpression(
"case when " . $helper->getSha1Function(static::getTableName().
".SEARCH_DEPARTMENT_CONTENT") .
" = '{$encryptedValue}' then ".static::getTableName().
".SEARCH_DEPARTMENT_CONTENT else '{$value}' end");
122 if (isset($updateData[
'SEARCH_ADMIN_CONTENT']))
124 $value = $DB->forSql($updateData[
'SEARCH_ADMIN_CONTENT']);
125 $encryptedValue = sha1($updateData[
'SEARCH_ADMIN_CONTENT']);
126 $updateData[
'SEARCH_ADMIN_CONTENT'] = new \Bitrix\Main\DB\SqlExpression(
"case when " . $helper->getSha1Function(static::getTableName().
".SEARCH_ADMIN_CONTENT") .
" = '{$encryptedValue}' then ".static::getTableName().
".SEARCH_ADMIN_CONTENT else '{$value}' end");
129 $merge = $helper->prepareMerge(
130 static::getTableName(),
131 static::getMergeFields(),
141 $result->setData($data);
145 $result->addError(
new Error(
'Error constructing query'));