D
D
Diversia2019-01-15 13:33:50
1C-Bitrix
Diversia, 2019-01-15 13:33:50

How to filter by multiple fields?

I can not figure out how to correctly form a request for a filter. It is necessary to search for two conditions in one query:
UF_ROLE => 8 + UF_PROFILE => 'N'
and
UF_ROLE => 7 + UF_PROFILE => 'Y'
I do this:

$arFilter = array(
    "ACTIVE" => 'Y',
    array(
        "LOGIC" => "OR",
        array('UF_ROLE' => 8, 'UF_PROFILE' => 'N'),
        array('UF_ROLE' => 7, 'UF_PROFILE' => 'Y'),
    ),
);


$result = \Bitrix\Main\UserTable::getList([
    'select' => ['ID', 'EMAIL', 'DATE_REGISTER', 'UF_ROLE',],
    //'order' => ['UF_ROLE' => 'DESC'],
    'filter' => $arFilter,
    //'limit' => 100
]);

while ($arUser = $result->fetch())
{
  // вывод
}

But it doesn't work. Please tell me what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2019-01-15
@winer

UF_ROLE and UF_PROFILE are not \Bitrix\Main\UserTable fields. Most likely you should have displayed an error with a message about this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question