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

About perl, doing SQL with an array

Quote Reply
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
Subject Author Views Date
Thread About perl, doing SQL with an array Robert 8588 Mar 14, 2014, 6:50 AM
Thread Re: [Robert] About perl, doing SQL with an array
Robert 8458 Mar 14, 2014, 6:55 AM
Post Re: [Robert] About perl, doing SQL with an array
Andy 8402 Mar 14, 2014, 7:09 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8430 Mar 14, 2014, 6:58 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8447 Mar 14, 2014, 7:08 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8504 Mar 14, 2014, 7:12 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8441 Mar 14, 2014, 8:15 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8496 Mar 14, 2014, 8:18 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8418 Mar 14, 2014, 9:53 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8410 Mar 14, 2014, 9:54 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8401 Mar 14, 2014, 10:15 AM
Thread Re: [Robert] About perl, doing SQL with an array
Robert 8399 Mar 14, 2014, 2:57 PM
Post Re: [Robert] About perl, doing SQL with an array
Andy 8374 Mar 15, 2014, 1:15 AM