Commit a0b128a9 authored by Leo Gordon's avatar Leo Gordon
Browse files

unifying change suggested by Andy

parent 67392217
......@@ -65,13 +65,12 @@ sub fetch_by_dbID {
sub store {
my ($self, $data) = @_;
my $data_id;
return 0 unless($data);
my $sth = $self->prepare("INSERT INTO analysis_data (data) VALUES (?)");
$sth->execute($data);
$data_id = ($self->dbc->driver eq 'sqlite') ? $self->dbc->db_handle->func('last_insert_rowid') : $sth->{'mysql_insertid'};
my $data_id = $self->dbc->db_handle->last_insert_id(undef, undef, 'analysis_data', 'analysis_data_id');
$sth->finish;
return $data_id;
......
......@@ -112,7 +112,7 @@ sub CreateNewJob {
my $sth = $dbc->prepare($sql);
$sth->execute($input_id, $prev_job_id, $analysis->dbID, $status, $semaphore_count || 0, $semaphored_job_id);
my $job_id = ($dbc->driver eq 'sqlite') ? $dbc->db_handle->func('last_insert_rowid') : $sth->{'mysql_insertid'};
my $job_id = $dbc->db_handle->last_insert_id(undef, undef, 'job', 'job_id');
$sth->finish;
$dbc->do("UPDATE analysis_stats SET ".
......
......@@ -315,7 +315,7 @@ sub store {
# using $return_code in boolean context allows to skip the value '0E0' ('no rows affected') that Perl treats as zero but regards as true:
or die "Could not perform\n\t$sql\nwith data:\n\t(".join(',', @$non_autoinc_values).')';
if($return_code > 0) { # <--- for the same reason we have to be expliticly numeric here
$self->mark_stored($object, ($driver eq 'sqlite') ? $self->dbc->db_handle->func('last_insert_rowid') : $sth->{'mysql_insertid'});
$self->mark_stored($object, $self->dbc->db_handle->last_insert_id(undef, undef, $table_name, $autoinc_id) );
}
}
}
......
......@@ -186,7 +186,7 @@ sub create_new_worker {
my $sth = $self->prepare($sql);
$sth->execute($meadow_type, $process_id, $exec_host, $analysisStats->analysis_id);
my $worker_id = ($self->dbc->driver eq 'sqlite') ? $self->dbc->db_handle->func('last_insert_rowid') : $sth->{'mysql_insertid'};
my $worker_id = $self->dbc->db_handle->last_insert_id(undef, undef, 'worker', 'worker_id');
$sth->finish;
my $worker = $self->fetch_by_dbID($worker_id);
......
......@@ -120,7 +120,8 @@ sub run {
$dbh->do( $sql );
my $insert_id_name = '_insert_id_'.$counter++;
my $insert_id_value = ($dbh->driver eq 'sqlite') ? $dbh->func('last_insert_rowid') : $dbh->{'mysql_insertid'};
#my $insert_id_value = ($dbh->driver eq 'sqlite') ? $dbh->func('last_insert_rowid') : $dbh->{'mysql_insertid'}; # <---- this approach worked
my $insert_id_value = $dbh->last_insert_rowid(); # <---- this one should work, but watch out
$output_id{$insert_id_name} = $insert_id_value;
$self->param($insert_id_name, $insert_id_value); # for templates
}
......
Markdown is supported
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