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

Re: [Vavilis] Add new table related to links

Quote Reply
Re: [Vavilis] Add new table related to links In reply to
For the first part of your question, yes, you can add new tables and add relations. For this, you'll use GT::SQL::Editor and GT::SQL::Creator. Full documentation is available in the help section of the admin panel.

You'll do something like this:
Code:
#!/perl/bin/perl
use strict;
use GT::Base;
use Links qw/$DB/;

my $table = $DB->creator("Links_Info");

$table->cols(
LinkID => { pos => 1, type => "INT", size => 11, not_null => 1 },
Example => { pos => 2, type => "VARCHAR", size => 255, not_null => 1}
);

$table->pk("LinkID");

$table->create();

$DB->editor("Links")->add_fk("Links_Info", { ID => "LinkID" });

I think you can sort on your foreign key relation. Under "build options", there's a section for sort orders. You may need to use "Links_Info.column_name" instead of just "column_name", but I'm not sure.

Searching I would assume would work fine. When you add foreign keys, records with matching fields between two tables get merged together when you run your queries. You might need to add a search weight property when you set up the table.

As per adding links, I'm not sure. You might need to use a hook to insert data into the new table. On the admin side, you'll need to use MySQLMan to manage your new table.

I hope that was a little helpful.

Philip
------------------
Limecat is not pleased.
Subject Author Views Date
Thread Add new table related to links Vavilis 1869 May 3, 2005, 12:50 AM
Post Re: [Vavilis] Add new table related to links
fuzzy logic 1778 May 3, 2005, 3:54 PM