#Insertion of extracted and synchronized data in 'article' table of e_slide database my $i_article; my $id_article; for ($i_article = 0; $i_article < @output_concord_files_prepare; $i_article++){ $dbh->do(" INSERT INTO `article`(`url`, `html_extr_text`,`concord_file`, `sys_time`) VALUES ('$url_prepare[$i_article]', '$html_pages_files_extended[$i_article]', '$output_concord_files_prepare[$i_article]', '$sys_time_prepare[$i_article]') ") || die $dbh->errstr; $id_article = $dbh->last_insert_id(undef, undef, 'article', 'id_article'); } #Insertion of extracted and synchonized data in 'event' table of e_slide database my $i_event; my $id_event; for ($i_event = 0; $i_event < @event_prepare; $i_event++){ $dbh->do(" INSERT INTO `event`(`event`) VALUES ('$event_prepare[$i_event]') ") || die $dbh->errstr; $id_event = $dbh->last_insert_id(undef, undef, 'event', 'id_event'); } #### my @fields = (qw(url html_extr_text concord_file sys_time)); my $fieldlist = join ", ", @fields; my $field_placeholders = join ", ", map {'?'} @fields; my $insert_query = qq{ INSERT INTO article($fieldlist) VALUES ($field_placeholders) }; my $sth = $dbh->prepare($insert_query); foreach my $article_index (0 .. @output_concord_files_prepare){ $field_placeholders = $sth->execute($url_prepare[$article_index], $html_pages_files_extended[$article_index], $output_concord_files_prepare[$article_index], $sys_time_prepare[$article_index]); if ($field_placeholders != 1){ die "Error inserting records, only [$field_placeholders] got inserted: " . $sth->insert->errstr; } }