Код |
---|
<? CModule::IncludeModule('iblock'); $resource = CIBlockElement::GetByID(ELEMENT_ID); if ($ob = $resource->GetNextElement()) { $arFields = $ob->GetFields(); $arFields['PROPERTIES'] = $ob->GetProperties(); $arFieldsCopy = $arFields; $arFieldsCopy['PROPERTY_VALUES'] = array(); foreach ($arFields['PROPERTIES'] as $property) { $arFieldsCopy['PROPERTY_VALUES'][$property['CODE']] = $property['VALUE']; } $el = new CIBlockElement(); $NEW_ID = $el->Add($arFieldsCopy); echo 'Элемент скопирован. ID нового элемента: '.$NEW_ID; } ?> |
Код |
---|
MSSQL Query Error: INSERT INTO b_iblock_element(ID, TIMESTAMP_X, MODIFIED_BY, DATE_CREATE, CREATED_BY, IBLOCK_ID, IBLOCK_SECTION_ID, ACTIVE, ACTIVE_FROM, ACTIVE_TO, SORT, NAME, PREVIEW_PICTURE, PREVIEW_TEXT, PREVIEW_TEXT_TYPE, DETAIL_PICTURE, DETAIL_TEXT, DETAIL_TEXT_TYPE, SEARCHABLE_CONTENT, WF_STATUS_ID, WF_PARENT_ELEMENT_ID, WF_NEW, WF_LOCKED_BY, WF_DATE_LOCK, WF_COMMENTS, IN_SECTIONS, XML_ID, CODE, TAGS, TMP_ID, WF_LAST_HISTORY_ID, SHOW_COUNTER, SHOW_COUNTER_START) VALUES(51696, convert (datetime, '2011-06-16 12:07:59', 120), '1', convert (datetime, '2011-06-16 12:07:59', 120), '1', '38', '2167', 'Y', convert (datetime, '2011-06-16 00:00:00', 120), convert (datetime, '2011-06-24 00:00:00', 120), '500', 'проверка копирования', , '', 'text', , '', 'text', 'ПРОВЕРКА КОПИРОВАНИЯ', '1', , ' ', , , , 'Y', '51696', , '', , , , ) #37000 [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near ','. |
Код |
---|
if ($property['PROPERTY_TYPE']=='L') $arFieldsCopy['PROPERTY_VALUES'][$property['CODE']]['VALUE_ENUM_ID'] = $property['VALUE_ENUM_ID']; |
Код |
---|
if ($property['PROPERTY_TYPE']=='F') { if ($property['MULTIPLE']=='Y') { if (is_array($property['VALUE'])) { foreach ($property['VALUE'] as $key => $arElEnum) $arFieldsCopy['PROPERTY_VALUES'][$property['CODE']][$key]=CFile::CopyFile($arElEnum); } }else $arFieldsCopy['PROPERTY_VALUES'][$property['CODE']] = CFile::CopyFile($property['VALUE']); } |