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

Products: Gossamer Links: Development, Plugins and Globals: About perl, doing SQL with an array: Edit Log

Here is the list of edits for this post
About perl, doing SQL with an array
Normally i use something like:

Code:

my $links_db=$DB->table ('Links', 'CatLinks', 'Category');
my $cond = GT::SQL::Condition->new(
'isValidated' => '=' => 'Yes',
'something' => '=' => '5',
);

$links_db->select_options ("GROUP BY Links.ID ORDER BY Mod_Date DESC", "LIMIT 30");
my $sth2 = $links_db->select( ['Links.ID','Title','URL'] => $cond );

while (my ($id,$title,$url) = $sth2->fetchrow_array) {
...
}


But for now i would like to have everything in an array.

So i can do:
Code:
my @ar;
...
while (my ($ar[ID],$ar[Title],ar) = $sth2->fetchrow_array) {[/code]


But i would like to have something like:
[code]my @ar;
...
while (my ($ar[]) = $sth2->fetchrow_array) {[/code]

Is this possible?

Or is there another way to have an array back without write every field in the code?
I have a lot of fields and i have a lot of selects. Because of this i try to write a sub and pass all the values to this sub.

I would like to have something like:

[code]
select * from ...
while $array = fields {

call sub ($array)

}
[/code]
With this i would save one million lines of code in my build.pm :)

Last edited by:

Robert: Mar 14, 2014, 6:54 AM

Edit Log: