A
A
Alexander Sinitsyn2016-10-14 17:08:03
1C-Bitrix
Alexander Sinitsyn, 2016-10-14 17:08:03

How to set an OR condition in a filter?

It is necessary to select elements with filled PROPERTY_TIME outside the period $from, $to and with empty PROPERTY_TIME. I did this, but it returns an empty selection, although there are such elements. So I understand that he joins the conditions through AND, but how to set OR?

$arFilter = Array(
        "IBLOCK_ID" => $iblock_id,
        "SECTION_ID" => $section_id,
        "INCLUDE_SUBSECTIONS" => "Y",
        "<PROPERTY_TIME" => array(false, date('Y-m-d H:i:s', $from)),
        ">PROPERTY_TIME" => array(false, date('Y-m-d H:i:s', $to)),
    );

    $elList = new CIBlockElement();
    $rs = $elList->GetList(
        Array("RAND" => "ASC"),
        $arFilter,
        false,
        Array("nTopCount" => 5),
        Array("ID", "NAME")
    );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-10-14
@a_u_sinitsin

Bitrix filter with complex logic site:dev.1c-bitrix.ru

array( 
"LOGIC" => "OR", 
"<PROPERTY_TIME" => array(false, date('Y-m-d H:i:s', $from)),
">PROPERTY_TIME" => array(false, date('Y-m-d H:i:s', $to)),
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question