Changeset 10923 for trunk/gsdl


Ignore:
Timestamp:
2005-11-23T12:15:42+13:00 (18 years ago)
Author:
jrm21
Message:

1) allow a 2nd sql query for 'priming' the db
2) add a space when concatenating multiple lines in config file
3) don't add metadata if the field data was NULL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/DBPlug.pm

    r10347 r10923  
    127127# then get pagename from "page" and content from "version" !
    128128
     129    my $sql_query_prime = undef ;
    129130    my $sql_query = undef ;
    130131
     
    142143    while (defined($line=<CONF>)) {
    143144    chomp $line;
     145    $line .= " "; # for multi-line statements - don't conjoin!
    144146    $line =~ s/\s*\#.*$//mg; # remove comments
    145147    $statement .= $line;
     
    210212    }
    211213
    212     my $statement_hand=$dbhandle->prepare($sql_query);
     214    my $statement_hand;
     215
     216    # The user gave 2 sql statements to execute?
     217    if ($sql_query_prime) {
     218        $statement_hand=$dbhandle->prepare($sql_query_prime);
     219        $statement_hand->execute;
     220        if ($statement_hand->err) {
     221            print $outhandle "Error: " . $statement_hand->errstr . "\n";
     222            return undef;
     223        }
     224    }
     225
     226    $statement_hand=$dbhandle->prepare($sql_query);
    213227    $statement_hand->execute;
     228    if ($statement_hand->err) {
     229        print $outhandle "Error: " . $statement_hand->errstr . "\n";
     230    return undef;
     231    }
    214232
    215233    # get the array-ref for the field names and cast it to array
     
    228246    }
    229247
    230 #    print "DBPlug: names: " . join (", ", @field_names) . ".\n";
    231248    # get rows
    232249
     
    278295    foreach my $fieldname (@field_names) {
    279296        my $fielddata=shift @row_array;
     297
     298        if (! defined($fielddata) ) {
     299            next; # this field was "" or NULL
     300        }
    280301        # use the specified encoding, defaulting to utf-8
    281302        if (defined($encoding) && $encoding ne "ascii"
Note: See TracChangeset for help on using the changeset viewer.