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

Re: [Robert] About perl, doing SQL with an array

Quote Reply
Re: [Robert] About perl, doing SQL with an array In reply to
Hi,

Quote:
I dont speak no single word of perl, i am just like a child playing with Lego. :)

hehe NP =)

Sounds like you would indeed be better with fetchrow_hashref. 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 ) || die $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
# you now have access to $hit->{ID}, $hit->{Title} and $hit->{URL}
do_stuff($hit);

# $hit will now have the values, including what was editing in do_stuff()
}

sub do_stuff {
# access $hit via $_[0]->{Field}, as this means you dont need to return anything (makes it quicker than doing a copy + return)
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread About perl, doing SQL with an array Robert 8680 Mar 14, 2014, 6:50 AM
Thread Re: [Robert] About perl, doing SQL with an array
Robert 8548 Mar 14, 2014, 6:55 AM
Post Re: [Robert] About perl, doing SQL with an array
Andy 8492 Mar 14, 2014, 7:09 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8520 Mar 14, 2014, 6:58 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8537 Mar 14, 2014, 7:08 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8595 Mar 14, 2014, 7:12 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8531 Mar 14, 2014, 8:15 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8587 Mar 14, 2014, 8:18 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8509 Mar 14, 2014, 9:53 AM
Thread Re: [Robert] About perl, doing SQL with an array
Andy 8500 Mar 14, 2014, 9:54 AM
Thread Re: [Andy] About perl, doing SQL with an array
Robert 8492 Mar 14, 2014, 10:15 AM
Thread Re: [Robert] About perl, doing SQL with an array
Robert 8489 Mar 14, 2014, 2:57 PM
Post Re: [Robert] About perl, doing SQL with an array
Andy 8465 Mar 15, 2014, 1:15 AM