S
S
SergPro2018-05-18 12:07:19
1C-Bitrix
SergPro, 2018-05-18 12:07:19

Multiple getlist calls or array filtering in php?

On the page, you need to insert a filtered list of infoblock elements in several places. Filter by infoblock property (list).
I saw three implementation options:
1) getlist->array()->array_filter->cycle We
form an array with one request. Then we split the array into parts according to the filter. We output the array in the right place.
2) getlist->array()->loop->condition Form an array with
one request. We display the array in the right place, filter through the condition inside the loop.
3) getlist(filter)->output
We make several getlist requests with filtering and immediately output.
What is the best way to do it and why? I'm not good at performance, but it seems to me that several getlist requests are worse than one, followed by filtering. In total, you need to make 5 filters for 35 records. I would be grateful if you share a link where to read about performance (for example, what will change if you need to make 30 filters, or there will be more than 1000 records).
In general, the question is: how to competently implement several filtrations in Bitrix with subsequent output?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
serginhold, 2018-05-18
@serginhold

if there is very little data and especially if they are all displayed, then the first or second option, whichever they are, is still one getList, then you just twist the array
if there is a lot of data, say 1000, and you need to display 3 blocks of 5 records with a different filter , then
either three getList,
or one getList with an OR filter, unless of course this ancient api devours a triple filter, but it seems that there are strictly two options
https://dev.1c-bitrix.ru/api_help/iblock/classes/c.. .Filter with complex logic

A
Alexey Ukolov, 2018-05-18
@alexey-m-ukolov

What is the best way to do it and why?
It is more correct to implement all three options and measure the performance of each. Thus, you will not only choose the best option, but also acquire the skill and be able to answer such questions yourself on the Toaster.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question