"cust_main.$field >= $beginning",
"cust_main.$field <= $ending";
- # XXX: do this for mysql and/or pull it out of here
if(defined $hour) {
- if ($dbh->{Driver}->{Name} eq 'Pg') {
+ if ($dbh->{Driver}->{Name} =~ /Pg/i) {
push @where, "extract(hour from to_timestamp(cust_main.$field)) = $hour";
}
+ elsif( $dbh->{Driver}->{Name} =~ /mysql/i) {
+ push @where, "hour(from_unixtime(cust_main.$field)) = $hour"
+ }
else {
warn "search by time of day not supported on ".$dbh->{Driver}->{Name}." databases";
}
}
$cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text
- my $username = $1;
+ my $username = lc($1);
- push @username_sql, "username ILIKE '$username'"
+ push @username_sql, "LOWER(username) LIKE '$username'"
if $username_type{'Exact'}
|| $username_type{'Fuzzy'};
- push @username_sql, "username ILIKE '\%$username\%'"
+ push @username_sql, "LOWER(username) LIKE '\%$username\%'"
if $username_type{'Substring'}
|| $username_type{'All'};
);
#if there was a Links.RemoteTarget int, this bs wouldn't be necessary
- my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS INTEGER)";
+ my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS ";
+ if ( RT->Config->Get('DatabaseType') eq 'mysql' ) {
+ $custnum_sql .= 'SIGNED INTEGER)';
+ }
+ else {
+ $custnum_sql .= 'INTEGER)';
+ }
if ( $subkey eq 'Number' ) {