D
D
dev4002016-08-12 15:00:11
PHP
dev400, 2016-08-12 15:00:11

How to make a check in the search for Bitrix?

Search works like this

$res = CIBlockElement::GetList(Array("SORT" => "DESC", "PROPERTY_REFERENCE" => "ASC"), $arFilter, false, false, $arSelect);

        if (  ) { //тут хочу проверить есть ли хоть один результат, вопрос что именно проверять, тк проверка if($res->GetNextElement()) обрубает если результат только один.

      while($ob = $res->GetNextElement()) {
        $arFields = $ob->GetFields();
                              //и т.д.
                          } else {
                        // когда ничего не найдено
                           }

How it is better to implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Zakharov, 2016-08-12
@dev400

if($res->SelectedRowsCount() > 0) {
   while($ob = $res->GetNextElement()) {
      $arFields = $ob->GetFields();
                              //и т.д.
   }
} else {
 если ничего не найдено
}

S
Sergey, 2016-08-12
@gangstarcj

If you do not have anything in the selection, then while will never work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question