package miscsql; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(sqlSelectMany sqlSelect); use strict; use Carp; sub sqlSelectMany { my($select,$from,$where,$other)=@_; my $sql="SELECT $select "; $sql.="FROM $from " if $from; $sql.="WHERE $where " if $where; $sql.="$other" if $other; my $c=$::dbh->prepare($sql); if($c->execute()) { return $c; } else { $c->finish(); return undef; } } sub sqlSelect { my ($select, $from, $where, $other)=@_; my $sql="SELECT $select "; $sql.="FROM $from " if $from; $sql.="WHERE $where " if $where; $sql.="$other" if $other; my $c=$::dbh->prepare($sql) or die "Sql has gone away\n"; if(not $c->execute()) { return undef; } my @r = $c->fetchrow(); $c->finish(); return @r; } 1;