G
G
Grigory Vasilkov2017-02-28 09:13:18
MySQL
Grigory Vasilkov, 2017-02-28 09:13:18

How to make a smart multi-JOIN + CASE-statement?

There is a concept of "section" in Bitrix. It's like a collection of admin sections (with key-value properties)
https://www.screencast.com/t/f9ESw5mYV5mP
The main difference from "elements" is that the properties of each section are stored in a separate table with a link by "infoblock" ID " - which essentially describes the appearance of both sections and elements (it is a kind of namespace) and a collection of "elements" at the same
time a couple of pieces)
The properties of each of the categories are set by the ID of this namespace. That is, the structure of the Bitrix database is something like this:
b_utm_iblock_1_section - multiple key-value
properties b_utm_iblock_2_section - multiple key-value
properties b_utm_iblock_3_section [n...] - multiple key-value
properties b_uts_iblock_1_section - single properties, where the key is the column name, and the value is the actual value
b_uts_iblock_2_section - single properties, where the key this is the name of the column, and the value is the actual value
b_uts_iblock_3_section [n...] - single properties, where the key is the name of the column, and the value is the actual
value forms) - a mixture of several storage formats, perhaps testing convenience.
So the actual question is:
How to competently pick up all these tables with properties depending on the selected sections? Like if a section has such and such an infoblock, connect both tables for it. It is clear that you can write 22 left-joins and generally create a query from PHP on the fly, but is there a way to write some tricky SELECT FROM SELECT so that it automatically JOINs one to the other, provided that there is "one more" in the selection? infoblock?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Vasilkov, 2017-02-28
@gzhegow

In short, they chattered, chatted, pointed out, explained, that's the solution.
sandbox.onlinephpfunctions.com/code/adb1eb06ae01c6...
"Illiterate", but fast and works.

A
Alexey Ukolov, 2017-02-28
@alexey-m-ukolov

How to competently pick up all these tables with properties depending on the selected sections?
Why not use the standard API? The Bitrixoids tweaked the database structure, but they also wrote the API for working with it.
Your giant complex query will most likely not be faster and will definitely not be cached.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question