Gossamer Forum
Quote Reply
Weird...
I'm just wondering. This only seems to happen on 2.1.2 ...

If I use the following code, it prints out a list of all the ID's correctly...

Code:
#!/usr/bin/perl

use strict;
use lib '/home/ameinfo/cgi-bin/events/admin';
use Links qw/$IN $DB $CFG/;
use GT::SQL;

local $SIG{__DIE__} = \&Links::fatal;

# FIRST GET ALL THE VARIABLES WE NEED....AND INCLUDE MODULES...

my $db = new GT::SQL '/home/ameinfo/cgi-bin/events/admin/defs';
my $table = $db->table ('Links');
my $sth = $table->select();


while (my $hit = $sth->fetchrow_hashref) {
print $hit->{ID} . "\n";
}


However, if I use the following code (also tried with $DB in replacement of $GT::SQL), but I then get an error saying "can't call 'table' on an undefined value"...Is it me, or shouldn't it do that? Crazy


Code:
#!/usr/bin/perl

use strict;
use lib '/home/ameinfo/cgi-bin/events/admin';
use Links qw/$IN $DB $CFG/;
use GT::SQL;

local $SIG{__DIE__} = \&Links::fatal;

# FIRST GET ALL THE VARIABLES WE NEED....AND INCLUDE MODULES...

my $table = $GT::SQL->table('Links');
my $sth = $table->select();


while (my $hit = $sth->fetchrow_hashref) {
print $hit->{ID} . "\n";
}

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!
Quote Reply
Re: [Andy] Weird... In reply to
It's you Tongue

Do you know what the $ infront of GT::SQL is doing?...have a think.
Quote Reply
Re: [Paul] Weird... In reply to
I'm assuming its a call to a module. Either way, it still doesn't work with $DB->table('Links') Unsure

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!
Quote Reply
Re: [Andy] Weird... In reply to
Quote:
I'm assuming its a call to a module.

$ is for a scalar isn't it :)

$foo, $bar

$GT::SQL->table

...is mixing a scalar with a method call so perl will barf.

$DB won't work because you never called Links::init('');

Crazy
Quote Reply
Re: [Andy] Weird... In reply to
As Paul mentioned, don't try to create a new GT::SQL object, use $DB, but it is not available until you call Links::init('/path/to/admin');

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Weird... In reply to
I'll have to remember that Crazy

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!