All pastes #497 Raw Edit

pfn

public text v1 · immutable
#497 ·published 2004-08-06 04:14 UTC
rendered paste body
sub insert_cfg_items {
    my($self, $filename, $category, $cat_metric, $listref) = @_;

    my $var_metric = 0;
    foreach my $line (@{$listref}) {
        my $commented = $line->{'commented'};
        my $var_name  = $line->{'var_name'};
        my $var_val   = $line->{'var_val'};

        my $sth = $self->{dbh}->prepare("INSERT INTO ast_config (cat_metric, var_metric, commented, filename, category, var_name, var_val) VALUES (?, ?, ?, ?, ?, ?, ?)");
        $sth->bind_param(1, $cat_metric);
        $sth->bind_param(2, $var_metric++);
        $sth->bind_param(3, $commented);
        $sth->bind_param(4, $filename);
        $sth->bind_param(5, $category);
        $sth->bind_param(6, $var_name);
        $sth->bind_param(7, $var_val);
        $sth->execute();
        if ($sth->err) {
            $self->{dberror} = $sth->errstr;
            return 0;
        }
    }

    1;
}