#--------------------------------------------------------------------------------------------------------# # Herstellen der Datenbankverbindung #--------------------------------------------------------------------------------------------------------# our $db = DBTools->new(); $dbh = $db->connect_($cfg->val('connection', 'data_source'), $cfg->val('connection', 'user'), $cfg->val('connection', 'pass')); #--------------------------------------------------------------------------------------------------------# # SQL aufbauen #--------------------------------------------------------------------------------------------------------# $sql = qq~ SELECT html, html2 FROM pkv.a_test_fetch ~; $sth = $dbh->prepare($sql) || &Error ("Datenbankfehler 1 prepare!\n",$dbh->errstr,""); $sth->execute() || &Error ("Datenbankfehler 1 execute!\n",$dbh->errstr,""); $sth->bind_columns(undef, \$html, \$html2) || &Error ("Datenbankfehler 1 bind_col!\n",$dbh->errstr,""); while(defined(&clean_html($sth->fetch()))){ print "\nHTML: $html\n"; print "\nHTML2: $html2\n"; }#ende while $sth->finish() || &Error ("Datenbankfehler 1 finish!\n",$dbh->errstr,""); #--------------------------------------------------------------------------------------------------------# # Subfunktion clean_html #--------------------------------------------------------------------------------------------------------# sub clean_html($){ my $array_ref = shift; if(ref($array_ref) eq 'ARRAY'){ my $counter = 0; foreach (@{$array_ref}) { @{$array_ref}[$counter] = CGI::escapeHTML($_); $counter++; }#ende foreach return $array_ref; } else{ return undef; } }#ende sub