Lines 204-209
sub get_matching_record_ids {
Link Here
|
204 |
|
204 |
|
205 |
my $fields = $args->{fields} // []; |
205 |
my $fields = $args->{fields} // []; |
206 |
my $tablename = $args->{tablename}; |
206 |
my $tablename = $args->{tablename}; |
|
|
207 |
my $exact_match = $args->{exact_match} // 1; |
207 |
return [] unless @$fields; |
208 |
return [] unless @$fields; |
208 |
|
209 |
|
209 |
my $dbh = C4::Context->dbh; |
210 |
my $dbh = C4::Context->dbh; |
Lines 222-234
sub get_matching_record_ids {
Link Here
|
222 |
WHERE afv.field_id = af.id |
223 |
WHERE afv.field_id = af.id |
223 |
AND af.name = ? |
224 |
AND af.name = ? |
224 |
AND af.tablename = ? |
225 |
AND af.tablename = ? |
225 |
AND value = ? |
226 |
AND value LIKE ? |
226 |
) AS field$i USING (id) |
227 |
) AS field$i USING (id) |
227 |
WHERE field$i.id IS NOT NULL |
228 |
WHERE field$i.id IS NOT NULL |
228 |
) AS values$i |; |
229 |
) AS values$i |; |
229 |
$subquery .= ' USING (record_id)' if $i > 1; |
230 |
$subquery .= ' USING (record_id)' if $i > 1; |
230 |
push @subqueries, $subquery; |
231 |
push @subqueries, $subquery; |
231 |
push @args, $field->{name}, $tablename, $field->{value}; |
232 |
push @args, $field->{name}, $tablename, ( $exact_match ? $field->{value} : "%$field->{value}%" ); |
232 |
} |
233 |
} |
233 |
$query .= join( ' LEFT JOIN ', @subqueries ) . ' WHERE 1'; |
234 |
$query .= join( ' LEFT JOIN ', @subqueries ) . ' WHERE 1'; |
234 |
for my $j ( 1 .. $i ) { |
235 |
for my $j ( 1 .. $i ) { |