D
D
Dmitry Igoshev2020-11-17 14:08:12
1C-Bitrix
Dmitry Igoshev, 2020-11-17 14:08:12

Bitrix ORM getList how to use data_doubling?

I have described an entity; it has a reference field PROFESSION.
I do getList with parameters:

$arFields   =   [
    'filter'        =>  ['!PROFESSION.ID'=>false],
    'select'        =>  ['NAME','ID'],
    'data_doubling' =>  false
];
$res    =   BranchTable::getList($arFields);

At the output, I get an array of records from BranchTable but with a bunch of duplicates.
How to use data_doubling correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-11-17
@Dreamod

for data_doubling = false to work, there must be an indication of the relationship in the description of the entity, in your case apparently OneToMany
Example

new \Bitrix\Main\ORM\Fields\Relations\OneToMany('PROFESSION', \Bitrix\Iblock\SectionTable::class, 'IBLOCK_SECTION')

Request example
$result = \Bitrix\Iblock\SectionTable::getList([
  'filter' => ['IBLOCK_ID' => 2, '!PROFESSION.ID' => false],
  'select' => ['NAME'],
  'data_doubling' => false
])->fetchAll();

Then the specified fields in the select, in the NAME example it is of the PROFESSION.NAME type, something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question