87 $result =
new Entity\AddResult();
89 $helper = Application::getConnection()->getSqlHelper();
92 $mergeFields = static::getMergeFields();
94 foreach ($mergeFields as $field)
96 unset($updateData[$field]);
100 $isPgCompatible = (version_compare($versionMain,
'24.0.0') >= 0);
102 if (isset($updateData[
'SEARCH_CONTENT']))
110 $field =
'SEARCH_CONTENT';
112 $updateData[
'SEARCH_CONTENT'] =
new SqlExpression($helper->getConditionalAssignment($field, $updateData[
'SEARCH_CONTENT']));
115 if (isset($updateData[
'SEARCH_TITLE']))
123 $field =
'SEARCH_TITLE';
125 $updateData[
'SEARCH_TITLE'] =
new SqlExpression($helper->getConditionalAssignment($field, $updateData[
'SEARCH_TITLE']));
128 $merge = $helper->prepareMerge(
129 static::getTableName(),
130 static::getMergeFields(),
137 Application::getConnection()->query($merge[0]);
138 $id = Application::getConnection()->getInsertedId();
144 $result->addError(
new Error(
'Error constructing query'));
153 $helper = Application::getConnection()->getSqlHelper();
155 if (isset($updateData[$primaryField]))
157 unset($updateData[$primaryField]);
160 if (isset($updateData[
'SEARCH_CONTENT']))
162 $updateData[
'SEARCH_CONTENT'] =
new SqlExpression($helper->getConditionalAssignment(
'SEARCH_CONTENT', $updateData[
'SEARCH_CONTENT']));
165 if (isset($updateData[
'SEARCH_TITLE']))
167 $updateData[
'SEARCH_TITLE'] =
new SqlExpression($helper->getConditionalAssignment(
'SEARCH_TITLE', $updateData[
'SEARCH_TITLE']));
170 $update = $helper->prepareUpdate(
171 static::getTableName(),
175 if ($update[0] !==
'')
177 $sql =
"UPDATE " . static::getTableName() .
" SET " . $update[0] .
" WHERE " . $primaryField .
" = " . $id;
178 self::safeUpdateIndex($sql);