[freeside-commits] branch master updated. 35b65801a513763ee70abade18d3a2c324daaf73
Ivan
ivan at 420.am
Mon Jul 24 13:34:25 PDT 2017
The branch, master has been updated
via 35b65801a513763ee70abade18d3a2c324daaf73 (commit)
from a1c1af9f78fd9b8892c43b4963ffa26ad42cb5af (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 35b65801a513763ee70abade18d3a2c324daaf73
Author: Ivan Kohler <ivan at freeside.biz>
Date: Mon Jul 24 13:34:24 2017 -0700
start of placeholder code path, type binding not working right yet
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 92e0baa..7e48690 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;
@@ -1349,21 +1352,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;
@@ -1374,7 +1400,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) ) {
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Record.pm | 50 ++++++++++++++++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 12 deletions(-)
More information about the freeside-commits
mailing list