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?
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
--Frank
Sep 4, 2004, 12:34 AM
Veteran / Moderator (18441 posts)
Sep 4, 2004, 12:34 AM
Post #4 of 5
Views: 2417
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);
$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!
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!
Sep 11, 2004, 8:47 AM
Veteran (1921 posts)
Sep 11, 2004, 8:47 AM
Post #5 of 5
Views: 2394
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.
http://www.yourdomain.com/...do=editor_update_def
changing NewTable to the name of your new table.