Simple Machines Community Forum

Archived Boards and Threads... => Archived Boards => SMF Feedback and Discussion => Aiheen aloitti: jeffmacguy - huhtikuu 02, 2008, 11:57:53 AP

Otsikko: Bulk-load boards at the db level
Kirjoitti: jeffmacguy - huhtikuu 02, 2008, 11:57:53 AP
Could someone tell me if it is possible to write a MySQL sql statement to insert a group of boards into a site. I would like to create individual boards for each US state and some sub-sets within the states and I don't look forward to the tedium of doing this through the user interface.

Any help would be appreciated.

Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: CmptrWz - huhtikuu 02, 2008, 12:05:58 IP
It is possible, yes. How proficient are you with mysql?
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: jeffmacguy - huhtikuu 02, 2008, 12:15:35 IP
proficient enough to not try anything on a production system... If I can make it work in test, then I'd give it a go on prod, after a full backup, of course.
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: CmptrWz - huhtikuu 02, 2008, 12:18:30 IP
At the very least you will need to insert into the boards table, perhaps the categories table as well. You may need to pre-prepare your data for ordering and subboard purposes as well, so you know what the other board IDs are. But, if you do it correctly, it should work.
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: H - huhtikuu 02, 2008, 12:23:05 IP
It might be easier to do something with one of SMF's functions:

http://support.simplemachines.org/function_db/index.php?action=view_function;function=9
http://support.simplemachines.org/function_db/index.php?action=view_function;function=118
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: jeffmacguy - huhtikuu 03, 2008, 09:58:58 AP
Thanks for the replies.

Huw: Can you provide an example of the input?

Thanks
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: H - huhtikuu 03, 2008, 04:06:06 IP
Say you had already made a category for these boards and then had all the US states in an array:

Example:


$usstates = array('New Jersey', 'New York');]

You could do:


require('/path/to/ssi.php');
require('/path/to/Sources/Subs-Boards.php');

$boardoptions = array (
'board_name' => 'name',
'inherit_permissions' => false,
'move_to' => 'no',
'target_category' => 1, //Change number to the category ID
)

foreach($usstate as $state)
{
   $boardoptions['board_name'] = $state;
   createboard($boardoptions);
}

I haven't tested this code but I think it should work :)
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: metallica48423 - huhtikuu 03, 2008, 04:27:46 IP
will throw an error if you try to direct load Subs-Boards, i believe.

add define('SMF', '1'); before you do anything.
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: H - huhtikuu 03, 2008, 04:29:33 IP
Lainaus käyttäjältä: metallica48423 - huhtikuu 03, 2008, 04:27:46 IP
will throw an error if you try to direct load Subs-Boards, i believe.

add define('SMF', '1'); before you do anything.

AFAIK this is already defined in SSI.php
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: metallica48423 - huhtikuu 03, 2008, 04:32:17 IP
Hm.  Possibly.  Its been awhile since i've done anything like this in conjunction with SSI :P
Otsikko: Re: Bulk-load boards at the db level
Kirjoitti: jeffmacguy - huhtikuu 03, 2008, 05:57:38 IP
Cool... thanks for the reply. I'll give it a shot and report on the results.