Gossamer Forum
Quote Reply
Table prefix question
Hi,

just installed GForum , now I wanted to use a global that I already use in Links SQL to display the number of total links in the database.

Now the problem is that the tables for GForum and Links have different prefixes, so I can't use the global from Links SQL without modifying it a bit.

In the documentation I found
Quote:
To set a prefix:

$db->prefix("foo");

to get the current prefix:

my $prefix = $db->prefix;

What this will do is prepend 'foo' to the beginning of every table name.

I tried that to set the table prefix according to my Links tables, but it won't work. Instead I get an error.

Can someone please tell me how to get data from tables with a different prefix?

Thank you.

Andreas
-------------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: [Digger] Table prefix question In reply to
Hi,

You can't use the $DB object as it's setup for Gossamer Forum. You need to create a new one, so your global would look like:

Code:
sub {
my $link_db = GT::SQL->new ("/path/to/links/admin/defs");
my $total = $link_db->table('Links')->count;
return $total;
}


Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Table prefix question In reply to
Hi Alex,

thank you. I tried it but now I'm getting another error message saying that it can't locate Links/Link.pm :

Quote:
GT::SQL (17601): Unable to load subclass: 'Links::Link'
Reason: Can't locate Links/Link.pm in @INC (@INC contains: /homepages/htdocs/cgi-bin/gforum/admin /usr/lib/perl5/5.00502/i586-linux /usr/lib/perl5/5.00502 /usr/lib/perl5/site_perl/5.005/i586-linux /usr/lib/perl5/site_perl/5.005 .) at /homepages/41/d34219801/htdocs/cgi-bin/gforum/admin/GT/SQL/Base.pm line 421.,

Can't locate Links.pm in @INC (@INC contains: /homepages/htdocs/cgi-bin/gforum/admin /usr/lib/perl5/5.00502/i586-linux /usr/lib/perl5/5.00502 /usr/lib/perl5/site_perl/5.005/i586-linux /usr/lib/perl5/site_perl/5.005 .) at /homepages/htdocs/cgi-bin/gforum/admin/GT/SQL/Base.pm line 421.
at (eval 22) line 3.

I think this is because I installed GForum in /cgi-bin/gforum while my LinksSQL installation is located in /cgi-bin/links2, so GForum searches for /cgi-bin/gforum/admin/Links/Link.pm instead of /cgi-bin/links2/admin/Links/Link.pm

Is there a way to tell the program the correct path?
Or maybe I can move all the subdirs of .../admin from Links and GForum to a common directory? How would I do that so that both programs can find the correct directories?

Andreas
-------------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: [Digger] Table prefix question In reply to
Oops, you need to load the path:

Code:
sub {
use lib '/full/path/to/lsql/admin';
my $link_db = GT::SQL->new ("/path/to/links/admin/defs");
my $total = $link_db->table('Links')->count;
return $total;
}

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Table prefix question In reply to
Thanx Alex,

now I'm one step further - I'm getting
Quote:
GT::SQL (31039): File '/homepages/htdocs/cgi-bin/links2/admin/defs/gforum_User.def' does not exist or the permissions are set incorrectly at (eval 23) line 1.
Crazy
Seems that I have to re-set the working dir after retrieving the value from the database ... how do I do that?

Andreas
-------------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: [Digger] Table prefix question In reply to
Hi,

Ack, sorry. This isn't going to work. In Links SQL 2.1.0, GT::SQL does not allow you to work off two different def_paths at the same time.

We fixed this a few weeks back, and the new GT::SQL libs in Gossamer Forum 1.1.2 will be working properly. So once you upgrade to 1.1.2, it should work fine (but you won't be able to do the reverse, put this global in Links SQL).

Cheers,

Alex
--
Gossamer Threads Inc.