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

GT::SQL won't work with 2 instances?

Quote Reply
GT::SQL won't work with 2 instances?
Hi,

I'm in the process of changing over from using DBI, to connect to 5 different databases (LSQL installs). These are all seperate installations on different servers (connected to via IP).

My code looks like;

Code:
use Links qw/$CFG $DB $IN/;

...and the Links::init() line too. Then, at the bottom of the script, I have a routine to load the SQL object;

Code:
sub loadConnection {

my $site = $_[0];

my $path = 'd:/uploads/new_scripts/defs/' . uc($site) . '/defs';
my $NEWDB = new GT::SQL (
def_path => $path,
cache => 0,
debug => 1,
subclass => 1
);

return $NEWDB;

}

This has worked perfectly on another script (which just grabs data from the main database, and then based on a value from that entry, it then distributes to the appropriate database, using the GT::SQL module.

However, in one of my scripts, it just refuses to work :/

Quote:
[Thu Apr 14 17:44:24 2005] redistribute.pl: GT:SQL::Table (1244): Could not con
nect to database: at d:/inetpub/wwwroot/domainc.om/main/a
dmin/GT/SQL/Driver.pm line 184.
Can't call method "fetchrow" on an undefined value at redistribute.pl line 147.

Anyone got any ideas? Unsure

TIA

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] GT::SQL won't work with 2 instances? In reply to
Code:
Can't call method "fetchrow" on an undefined value at redistribute.pl line 147


This is a nasty error. I actually sent Alex a pm on this, in general, about making the module a tad more responsive to this.

Look at line 147, and figure out why the statement handle is _empty_ or null.

There *are* some bugs, for example, in the case I had, I was "sb=col_name" but col_name did not exist on that table. The query executed, and returned 2 rows, therefor $sth->rows was 2, and $db->hits was 2, but the $sth->fetchrow_* command was returning "null" or undefined.

Also, something ielse t doesn't like, is if you are passing a hash/hash_ref to Site::HTML for display, if (one of) the hash_ref is null, it returns an error as well. Hashes are not "magic" all the way down. So, if you are passing in a Links_Rec and a Review_Rec, and th eReview_Rec is null (because there are no reviews) you need to flatten the hashes BEFORE passing them, or check to make sure you have a defined Review_Rec and deal with it using if/else statements.

Example: {%$rec, %$rec2, template=>'trouble', other_arg=>'here'}

If $rec2 is undefined, this will bomb, inelegantly!

It makes sense, actually, when you look at the code but it's just something else with hashes you have to handle in any routines where a hash-ref may not actually contain data.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Andy] GT::SQL won't work with 2 instances? In reply to
Did you try to check the content of $NEWDB object before returning it?
Try to print it with the Data::Dumper module.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] GT::SQL won't work with 2 instances? In reply to
LOL ... got it working =) For some reason, CuteFTP wasn't updating the database.def file correctly, and it was trying to connect to localhost, which wouldn't work (as its on an IP rather than the same machine).

Thanks for the replies guys :)

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!