Various changes not checked in previously because source forge was down.

This commit is contained in:
JT Smith 2002-11-18 00:12:33 +00:00
parent a06ad50cac
commit 8966e401c3
8 changed files with 298 additions and 46 deletions

View file

@ -20,6 +20,7 @@ use strict;
use Tie::IxHash;
use WebGUI::ErrorHandler;
use WebGUI::Session;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&quote &getNextId);
@ -45,8 +46,10 @@ our @EXPORT = qw(&quote &getNextId);
%hash = WebGUI::SQL->buildHash($sql);
$hashRef = WebGUI::SQL->buildHashRef($sql);
@arr = WebGUI::SQL->quickArray($sql);
$text = WebGUI::SQL->quickCSV($sql);
%hash = WebGUI::SQL->quickHash($sql);
$hashRef = WebGUI::SQL->quickHashRef($sql);
$text = WebGUI::SQL->quickTab($sql);
WebGUI::SQL->write($sql);
@ -336,6 +339,37 @@ sub quickArray {
}
#-------------------------------------------------------------------
=head2 quickCSV ( sql [, dbh ] )
Executes a query and returns a comma delimited text blob with column
headers.
=item sql
An SQL query.
=item dbh
By default this method uses the WebGUI database handler. However,
you may choose to pass in your own if you wish.
=cut
sub quickTab {
my ($sth, $output, @data);
$sth = WebGUI::SQL->new($_[1],$_[2]);
$output = join(",",$sth->getColumnNames)."\n";
while (@data = $sth->array) {
makeArrayCommaSafe(\@data);
$output .= join(",",@data)."\n";
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
=head2 quickHash ( sql [, dbh ] )
@ -393,6 +427,36 @@ sub quickHashRef {
#-------------------------------------------------------------------
=head2 quickTab ( sql [, dbh ] )
Executes a query and returns a tab delimited text blob with column
headers.
=item sql
An SQL query.
=item dbh
By default this method uses the WebGUI database handler. However,
you may choose to pass in your own if you wish.
=cut
sub quickTab {
my ($sth, $output, @data);
$sth = WebGUI::SQL->new($_[1],$_[2]);
$output = join("\t",$sth->getColumnNames)."\n";
while (@data = $sth->array) {
makeArrayTabSafe(\@data);
$output .= join("\t",@data)."\n";
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
=head2 quote ( string )
Returns a string quoted and ready for insert into the database.