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

How do you create a new def file?

Quote Reply
How do you create a new def file?
I created a new table. I'd like to access Links SQL classes, but it says I need a .def file. How do I create one?
Quote Reply
Re: [dwh] How do you create a new def file? In reply to
I think you can look in the admin/defs directory where you can see examples of the def files for the various tables for Links SQL. You would need to create a new file in a similar format for your new table, name it accordingly, and then place it in this same defs directory.

--Frank
Quote Reply
Re: [FrankM] How do you create a new def file? In reply to
I tried that but didn't understand the format...a bunch of weird stuff in there..
Quote Reply
Re: [dwh] How do you create a new def file? In reply to
You're best bet is to look into GT::SQL::Creator, which will let you make a new .def file, as well as the table. Basic format looks like (taken out of my PPC plugin);

Code:
$creator=$DB->creator('Keywords');
$creator->cols(
Keyword_ID => {
pos => 1,
type => 'INT',
not_null => 1
},
Keyword => {
pos => 2,
type=> 'CHAR',
not_null => 1
},
Num_Searches => {
pos => 3,
type => 'INT',
},
Status => {
pos =>4,
type => 'ENUM',
values => ['Active','Deleted'],
default => 'Active'
}
);
$creator->pk('Keyword_ID');
$creator->ai('Keyword_ID');
$creator->create or $table_errors.= "Unable to create: $GT::SQL::error<br>";

Hope that helps.

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: [dwh] How do you create a new def file? In reply to
The other way of doing this is just to copy an existing def file and rename it with the new table name. Then resync the new table using

http://www.yourdomain.com/...do=editor_update_def

changing NewTable to the name of your new table.