summaryrefslogtreecommitdiff
path: root/FS/FS/Record.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-07-24 13:34:26 -0700
committerIvan Kohler <ivan@freeside.biz>2017-07-24 13:34:26 -0700
commitb9b9f0dbf96655eff2fb020ce7c0f61dac19592a (patch)
treef60608e3d2f31e86fc4f472a172b8d4f68b9f770 /FS/FS/Record.pm
parente07dc02b9570db1a6b7425fa73232678e61364e2 (diff)
start of placeholder code path, type binding not working right yet
Diffstat (limited to 'FS/FS/Record.pm')
-rw-r--r--FS/FS/Record.pm50
1 files changed, 38 insertions, 12 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index dd26ea9..514520e 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -6,6 +6,7 @@ use charnames ':full';
use vars qw( $AUTOLOAD
%virtual_fields_cache %fk_method_cache $fk_table_cache
$money_char $lat_lower $lon_upper
+ $use_placeholders
);
use Carp qw(carp cluck croak confess);
use Scalar::Util qw( blessed );
@@ -41,6 +42,8 @@ our @EXPORT_OK = qw(
our $DEBUG = 0;
our $me = '[FS::Record]';
+$use_placeholders = 0;
+
our $nowarn_identical = 0;
our $nowarn_classload = 0;
our $no_update_diff = 0;
@@ -1348,21 +1351,44 @@ sub insert {
grep { defined($self->getfield($_)) && $self->getfield($_) ne "" }
real_fields($table)
;
- my @values = map { _quote( $self->getfield($_), $table, $_) } @real_fields;
- #eslaf
my $statement = "INSERT INTO $table ";
- if ( @real_fields ) {
- $statement .=
- "( ".
- join( ', ', @real_fields ).
- ") VALUES (".
- join( ', ', @values ).
- ")"
- ;
- } else {
+ my @bind_values = ();
+
+ if ( ! @real_fields ) {
+
$statement .= 'DEFAULT VALUES';
+
+ } else {
+
+ if ( $use_placeholders ) {
+
+ @bind_values = map $self->getfield($_), @real_fields;
+
+ $statement .=
+ "( ".
+ join( ', ', @real_fields ).
+ ") VALUES (".
+ join( ', ', map '?', @real_fields ). # @bind_values ).
+ ")"
+ ;
+
+ } else {
+
+ my @values = map { _quote( $self->getfield($_), $table, $_) } @real_fields;
+
+ $statement .=
+ "( ".
+ join( ', ', @real_fields ).
+ ") VALUES (".
+ join( ', ', @values ).
+ ")"
+ ;
+
+ }
+
}
+
warn "[debug]$me $statement\n" if $DEBUG > 1;
my $sth = dbh->prepare($statement) or return dbh->errstr;
@@ -1373,7 +1399,7 @@ sub insert {
local $SIG{TSTP} = 'IGNORE';
local $SIG{PIPE} = 'IGNORE';
- $sth->execute or return $sth->errstr;
+ $sth->execute(@bind_values) or return $sth->errstr;
# get inserted id from the database, if applicable & needed
if ( $db_seq && ! $self->getfield($primary_key) ) {