package WebGUI::Widget::SQLReport;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub widgetName {
return "SQL Report";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '
'; } @template = split(/\^\-/,$data{template}); $output .= $template[0]; $dbh = DBI->connect($data{DSN}, $data{username}, $data{identifier}); if (defined $dbh) { $sth = WebGUI::SQL->read($data{dbQuery},$dbh); if (defined $sth) { while (@result = $sth->array) { $temp = $template[1]; $temp =~ s/\^(\d)/$result[$1]/g; $output .= $temp; } $sth->finish; } else { $output .= 'Error: There was a problem with the query.'; } } else { $output .= 'Error: Could not connect to remote database.'; } $output .= $template[2]; } if ($data{processMacros} == 1) { $output = WebGUI::Macro::process($output); } return $output; } 1;