Skip to content
Snippets Groups Projects
Commit 18a4df8c authored by Andy Yates's avatar Andy Yates
Browse files

Slight re-working of method to avoid insert id issues and to still take in attributes

parent bef21083
No related branches found
No related tags found
No related merge requests found
...@@ -703,14 +703,18 @@ sub last_insert_id { ...@@ -703,14 +703,18 @@ sub last_insert_id {
my ($self, $field, $attributes, $table) = @_; my ($self, $field, $attributes, $table) = @_;
my $dbc = $self->dbc(); my $dbc = $self->dbc();
my $dbh = $dbc->db_handle(); my $dbh = $dbc->db_handle();
my @args;
if($dbc->driver() eq 'mysql') { if($dbc->driver() eq 'mysql') {
return $dbh->last_insert_id(); @args = (undef,undef,undef,undef);
} }
$attributes ||= {}; else {
if(!$table) { if(!$table) {
($table) = $self->_tables(); ($table) = $self->_tables();
}
@args = (undef, $dbc->dbname(), $table->[0], $field);
} }
return $dbh->last_insert_id(undef, $dbc->dbname(), $table->[0], $field, $attributes); $attributes ||= {};
return $dbh->last_insert_id(@args, $attributes);
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment