diff options
author | ivan <ivan> | 2001-12-10 12:18:53 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-12-10 12:18:53 +0000 |
commit | c88ce379ab3075629aed1c674124c8ca13ad7dbe (patch) | |
tree | 0994897b40390fbf1f3a38599e763270d09fd235 /FS | |
parent | f80ce3a22396ec4290a6fdd8ae74cea05f335ec8 (diff) |
Pg datatype pain
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Record.pm | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index a04ddb982..995e4bdc2 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -7,6 +7,7 @@ use Exporter; use Carp qw(carp cluck croak confess); use File::CounterFile; use Locale::Country; +use DBI qw(:sql_types); use DBIx::DBSchema 0.19; use FS::UID qw(dbh checkruid getotaker datasrc driver_name); use FS::SearchCache; @@ -225,9 +226,26 @@ sub qsearch { my $sth = $dbh->prepare($statement) or croak "$dbh->errstr doing $statement"; - $sth->execute( map $record->{$_}, + my $bind = 1; + + foreach my $field ( grep defined( $record->{$_} ) && $record->{$_} ne '', @fields - ) or croak "Error executing \"$statement\": ". $sth->errstr; + ) { + if ( $record->{$field} =~ /^\d+(\.\d+)?$/ + && $dbdef->table($table)->column($field)->type =~ /(int)/i + ) { + $sth->bind_param($bind++, $record->{$field}, SQL_INTEGER ); + } else { + $sth->bind_param($bind++, $record->{$field}, SQL_VARCHAR ); + } + } + +# $sth->execute( map $record->{$_}, +# grep defined( $record->{$_} ) && $record->{$_} ne '', @fields +# ) or croak "Error executing \"$statement\": ". $sth->errstr; + + $sth->execute or croak "Error executing \"$statement\": ". $sth->errstr; + $dbh->commit or croak $dbh->errstr if $FS::UID::AutoCommit; if ( eval 'scalar(@FS::'. $table. '::ISA);' ) { |