Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Array instead $link->{fieldname}

Quote Reply
Array instead $link->{fieldname}
Hy all, i try to read some data with

Code:
sub {
my $tags = shift;
my $lid = $tags->{ID};
my $output;
my ( $db, $sth, $link, $cond);
$db = $DB->table ('PoInfo');
$db->select_options('LIMIT 1');
$sth = $db->select ({LinkID => $lid });

while ($link = $sth->fetchrow_hashref) {
****
}
return $output;
}


My Problem now is to read the data from the table inside an array to use later a for next loop.
Now i could get it with

my $lala = $link->{fieldname};

but cause i have a lot of fields, i wont do:

$a[0] = $link->{fieldname_0};
$a[1] = $link->{fieldname_1};
...
$a[n] = $link->{fieldname_n};

There must be a way to get it on antoher way, isnīt it?

Better than this would be something like:

get all field_names from table where value = 1
as i could do it with php.

Some ideas?
Robert
Quote Reply
Re: [Robert] Array instead $link->{fieldname} In reply to
OK, got it:

Code:
sub {
my $tags = shift;
my $lid = $tags->{ID};
my $output = "lol"; my @row;
my ( $db, $sth, $link, $cond);
$db = $DB->table ('PoInfo');
$db->select_options('LIMIT 1');
$sth = $db->select ({LinkID => $lid });
while ( @row = $sth->fetchrow_array() ) { $output .="$row[0]";

}
return $output;
}