Gossamer Forum
Quote Reply
Extern table
To work with an extern table with lsql is really easy; just add a .def and add the tablename to dbnav.html (admin templates); then resync and ready to go.

Now i have the problem that my lsql has a prefix, but the extern table not and i cant change this.
Lsql wants to work now with prefix_externtable.

Anyway i need to count something from this table; is this possible without the .def file and without the prefix in the name of the table?

Maybe we had this before, and you, Andy, has told me a solution how to query an extern table?
Quote Reply
Re: [Robert] Extern table In reply to
Is it in the same database as GLinks? If so, you can do a little trick with:

Code:
my $count = $DB->table("Changes")->do_query(qq|SELECT COUNT(*) FROM your_table|)->fetchrow;

The table in red can be any valid GLinks table (it's literally just to make the connection)

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: [Robert] Extern table In reply to
Quote:
To work with an extern table with lsql is really easy; just add a .def and add the tablename to dbnav.html (admin templates); then resync and ready to go.
Can you please explain this in detail and how this can be used? Would appreciate it. Thanks!
Quote Reply
Re: [Robert] Extern table In reply to
If you need more tables then lsql has, you can add them easily when the have the same prefix;
if not you need the code written by andy to fetch or write data from them, because lsql normally adds the prefix to the table name.
Quote Reply
Re: [Robert] Extern table In reply to
Hi,

This plugin (attached) is a nice way to manage / create new tables. It was created by jggamble: http://www.gossamer-threads.com/...?post=298948#p298948

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] Extern table In reply to
Nice to know; normally i use phpMyAdmin, manipulate one admin template to use the table in the admin area with all normal possibilities like resync and so on.
Quote Reply
Re: [Robert] Extern table In reply to
Finally i have used it

my $count = $DB->table("Changes")->do_query(qq|SELECT COUNT(*) FROM your_table|)->fetchrow;

and it works fine; but how to spell it for more than one value?

my ($title, $rc) = $DB->table("Changes")->do_query(qq|SELECT title, reply_count FROM thread WHERE threadid = '$t'|)->fetchrow;
Ok, it works. :)

Last edited by:

Robert: Nov 23, 2017, 10:06 AM
Quote Reply
Re: [Robert] Extern table In reply to
Hi,

Yup - you should be able to use fetchrow/fetchrow_hashref/fetchrow_arrayref/etc with the do_query()

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!