Answer the question
In order to leave comments, you need to log in
How to simplify the processing of a very large form?
Was digging through my archives... and found one big statistical form. Search for objects by a huge cloud of parameters.
Roughly speaking, the query is as follows: SELECT * FROM ... as A
INNER
JOIN ... as B .... and so 6 tables WHERE 1=1 and then dozens
AND we get ... AND pokazatel IN ($checkbox_values)
there is a field (select > < =) and a text input, then we get AND pokazatel $select_value.$input_value
in general, the bottom line is that each indicator then had to be written with pens ... it turned out about 3000 thousand lines) and now change something ... it's easier to delete everything.
Have a recipe? where to read and see?
Answer the question
In order to leave comments, you need to log in
I would create an array of options, something like
$data = [1 => ['param' => 'name', 'cond' =>'=', 'value' => $name],
2 => ['param' => 'age', 'cond' =>'>', 'value' => $age],
.......
]
For ordinary users, this filter form can be simplified. For advanced users, provide the ability to write filters in a pseudo-language using "AND/OR", "CONTAINS", etc. Then just parse the string, parse it and make a normal query.
Or you collect all the information from the form in xml and send it to the database, where you parse it into components. When changing the form (adding new columns), it will only be necessary to change the parsing procedure in the database. And if you write a universal one, then you don’t have to do this either.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question