Revision e285ec14
Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt
- ID e285ec14e2a7c89d408a51b6731e968218c92c7f
- Vorgänger c2342266
SL/CVar.pm | ||
---|---|---|
104 | 104 |
|
105 | 105 |
my $sub_module = $params{sub_module} ? $params{sub_module} : ''; |
106 | 106 |
|
107 |
my $q_var = |
|
108 |
qq|SELECT text_value, timestamp_value, timestamp_value::date AS date_value, number_value, bool_value |
|
107 |
my $custom_variables = $self->get_configs(module => $params{module}); |
|
108 |
|
|
109 |
my $q_var = |
|
110 |
qq|SELECT config_id, text_value, timestamp_value, timestamp_value::date AS date_value, number_value, bool_value |
|
109 | 111 |
FROM custom_variables |
110 |
WHERE (config_id = ?) AND (trans_id = ?) AND (sub_module = ?)|;
|
|
111 |
my $h_var = prepare_query($form, $dbh, $q_var);
|
|
112 |
WHERE (config_id IN (| . join(', ', ('?') x scalar( @$custom_variables )) . qq|))
|
|
113 |
AND (trans_id = ?) AND (sub_module = ?)|;
|
|
112 | 114 |
|
113 |
my $custom_variables = $self->get_configs(module => $params{module}); |
|
115 |
my $results_var = []; |
|
116 |
if ($params{trans_id} && scalar( @$custom_variables )) { |
|
117 |
$results_var = selectall_hashref_query($form, $dbh, $q_var, (map( { conv_i($_->{id}) } @$custom_variables), conv_i($params{trans_id}), $sub_module)); |
|
118 |
} |
|
114 | 119 |
|
115 | 120 |
foreach my $cvar (@{ $custom_variables }) { |
116 | 121 |
if ($cvar->{type} =~ m{^(?:html|text)field}) { |
... | ... | |
132 | 137 |
|
133 | 138 |
my ($act_var, $valid); |
134 | 139 |
if ($params{trans_id}) { |
135 |
my @values = (conv_i($cvar->{id}), conv_i($params{trans_id}), $sub_module); |
|
136 |
|
|
137 |
do_statement($form, $h_var, $q_var, @values); |
|
138 |
$act_var = $h_var->fetchrow_hashref(); |
|
139 |
|
|
140 |
$act_var = first { $_->{config_id} == $cvar->{id} } @$results_var; |
|
140 | 141 |
$valid = $self->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{trans_id}, sub_module => $params{sub_module}); |
141 | 142 |
} else { |
142 | 143 |
$valid = !$cvar->{flag_defaults_to_invalid}; |
... | ... | |
194 | 195 |
} |
195 | 196 |
} |
196 | 197 |
|
197 |
$h_var->finish(); |
|
198 |
|
|
199 | 198 |
$main::lxdebug->leave_sub(); |
200 | 199 |
|
201 | 200 |
return $custom_variables; |
Auch abrufbar als: Unified diff
S::CVar->get_custom_variables beschleunigt, …
… indem CVar-values aller Variablen einer trans_id gleichzeitig geholt werden.
Das beschleunigt z.B. das Laden von Rechnungen mit vielen Positionen stark,
wenn viele benutzerdef. Variablen bei Waren hinterlegt sind.
Im Test mit 30 Positionen und 30 Variablen um ca. das 10-fache.