add backticks around field names because some like Function are reserved

This commit is contained in:
Isaac Connor 2022-01-12 23:08:29 -05:00
parent 8d06175024
commit e4693c251c
1 changed files with 5 additions and 5 deletions

View File

@ -639,9 +639,9 @@ $log->debug("Have array for $k $$search{$k}") if DEBUG_ALL;
if ( ! ( $db_field =~ /\?/ ) ) { if ( ! ( $db_field =~ /\?/ ) ) {
if ( @{$$search{$k}} != 1 ) { if ( @{$$search{$k}} != 1 ) {
push @where, $db_field .' IN ('.join(',', map {'?'} @{$$search{$k}} ) . ')'; push @where, '`'.$db_field .'` IN ('.join(',', map {'?'} @{$$search{$k}} ) . ')';
} else { } else {
push @where, $db_field.'=?'; push @where, '`'.$db_field.'`=?';
} # end if } # end if
} else { } else {
$log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL; $log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
@ -656,10 +656,10 @@ $log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
foreach my $p_k ( keys %{$$search{$k}} ) { foreach my $p_k ( keys %{$$search{$k}} ) {
my $v = $$search{$k}{$p_k}; my $v = $$search{$k}{$p_k};
if ( ref $v eq 'ARRAY' ) { if ( ref $v eq 'ARRAY' ) {
push @where, $db_field.' IN ('.join(',', map {'?'} @{$v} ) . ')'; push @where, '`'.$db_field.'` IN ('.join(',', map {'?'} @{$v} ) . ')';
push @values, $p_k, @{$v}; push @values, $p_k, @{$v};
} else { } else {
push @where, $db_field.'=?'; push @where, '`'.$db_field.'`=?';
push @values, $p_k, $v; push @values, $p_k, $v;
} # end if } # end if
} # end foreach p_k } # end foreach p_k
@ -667,7 +667,7 @@ $log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
push @where, $db_field.' IS NULL'; push @where, $db_field.' IS NULL';
} else { } else {
if ( ! ( $db_field =~ /\?/ ) ) { if ( ! ( $db_field =~ /\?/ ) ) {
push @where, $db_field .'=?'; push @where, '`'.$db_field .'`=?';
} else { } else {
push @where, $db_field; push @where, $db_field;
} }