Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Script to add forums

Quote Reply
Script to add forums
I want to add a forum through a script. The code I have is
Code:
my $fdb = new GT::SQL '/../admin/defs';
my $f_forum_db = $fdb->table('Forum');

# Add forum in Forum table
$f_forum_db->add ({
forum_id => $forum_id,
cat_id_fk => $cat_id_fk,
forum_name => $forum_name,
forum_desc => $forum_desc,
forum_total => 0,
forum_total_threads => 0,
forum_last => 0,
forum_last_poster => '',
forum_last_id => 0,
forum_sort_rank => 0,
forum_style => 1,
forum_allow_attachments => 1,
forum_allow_guest_attachments => 1,
forum_attachments => 0,
forum_allow_user_edit => 3,
forum_edit_timout => 0,
forum_hard_delete => 2
});
When I execute it, it adds a forum, but gives me the error: Can't call method "table" on an undefined value at /.../Forum.pm line 213.

Does anyone know what I have to change/add in order to prevent this error?

BTW, it works fine if I use the "insert" method instead of the "add" method.

Thanks a lot.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Script to add forums In reply to
Your syntax looks correct. Just double check that the path to the defs is correct or even use the full path to make sure it is working.

I'm not sure why using insert instead of add gets rid of the error as the error is occuring on the previous line.

You may be able to get an error message from $GT::SQL::error

Last edited by:

RedRum: Feb 12, 2002, 8:07 AM
Quote Reply
Re: [yogi] Script to add forums In reply to
Use:

Code:
use lib '/path/to/gforum/admin';
use GForum qw/$DB/;
GForum::init('/path/to/gforum/admin');

my $forum_db = $DB->table('Forum');


to start your program as this will properly initilize Gossamer Forum.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Script to add forums In reply to
The docs will need to be updated Unsure
Quote Reply
Re: [Alex] Script to add forums In reply to
Thanks, Alex.

I will try that tomorrow.

Ivan
-----
Iyengar Yoga Resources / GT Plugins