@@ -, +, @@ my $objects = $module->search( { $key => { -in => $values } } ); select borrowernumber from borrowers where borrowernumber in (5, 3, 1); select borrowernumber from borrowers where borrowernumber=5 or borrowernumber=3 or borrowernumber=1; --- C4/Letters.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/C4/Letters.pm +++ a/C4/Letters.pm @@ -1596,7 +1596,18 @@ sub _get_tt_params { croak "ERROR processing table $table. Wrong API call."; } my $key = $pk ? $pk : $fk; - my $objects = $module->search( { $key => { -in => $values } } ); + # $key does not come from user input + my $objects = $module->search( + { $key => $values }, + { + # We want to retrieve the data in the same order + # FIXME MySQLism + # field is a MySQLism, but they are no other way to do it + # To be generic we could do it in perl, but we will need to fetch + # all the data then order them + @$values ? ( order_by => \[ "field($key, " . join( ', ', @$values ) . ")" ] ) : () + } + ); $params->{ $config->{$table}->{plural} } = $objects; } elsif ( $ref eq q{} || $ref eq 'HASH' ) { --