I use this global, and the if statment is never work even when there is a value to the uid.
use GT::SQL::Condition;
my $total = 0;
my $qqq = $_[2];
my $aaa = $_[3];
my $uid = $_[4];
my $tbl = $DB->table('FormDetails');
$tbl->select_options("ORDER BY ID DESC Limit $qqq, $aaa");
my $cond = new GT::SQL::Condition;
my $cond = GT::SQL::Condition->new($_[0] => $_[1]);
my $cond2 = new GT::SQL::Condition;
if ($uid)
{
my $cond2 = GT::SQL::Condition->new( Username => $_[4]);}
my $sth = $tbl->select( $cond, $cond2 ) || return $GT::SQL::error;
$total = $tbl->hits;
my @back;
while (my $hit = $sth->fetchrow_hashref) {
push @back, $hit;
} my $exists; if ($back[0]) { $exists = 1; } else { $exists = ''; }
return { lead_loop => \@back, link_count => $total} }
Code:
sub { use GT::SQL::Condition;
my $total = 0;
my $qqq = $_[2];
my $aaa = $_[3];
my $uid = $_[4];
my $tbl = $DB->table('FormDetails');
$tbl->select_options("ORDER BY ID DESC Limit $qqq, $aaa");
my $cond = new GT::SQL::Condition;
my $cond = GT::SQL::Condition->new($_[0] => $_[1]);
my $cond2 = new GT::SQL::Condition;
if ($uid)
{
my $cond2 = GT::SQL::Condition->new( Username => $_[4]);}
my $sth = $tbl->select( $cond, $cond2 ) || return $GT::SQL::error;
$total = $tbl->hits;
my @back;
while (my $hit = $sth->fetchrow_hashref) {
push @back, $hit;
} my $exists; if ($back[0]) { $exists = 1; } else { $exists = ''; }
return { lead_loop => \@back, link_count => $total} }