News:

Wondering if this will always be free?  See why free is better.

Main Menu

Double database

Started by The -L-, September 12, 2009, 12:12:25 PM

Previous topic - Next topic

Arantor

Unfortunately it isn't as simple as that; SMF 2.0 contains 63 different tables that are all inter-related; sure it's possible to do but it's a LOT of work to do without screwing it all up.

The -L-

Any experts that can do this?

Arantor

There are two ways you can approach this.

It really depends on a few things, though. Should an account on one be completely and utterly linked to the other, e.g. post count increments on the account with a post on either forum?

Or should the two forums be independent but have joint accounts made - i.e. an account created on one registers an account on the other (leading to users with different passwords on each account over time if users want, different post counts)

The former is a HUGE amount of work as it requires numerous changes throughout SMF's source, though it's more than doable (I've done something similar before). The latter is a lot less work, but of course not as unified.

The -L-

Account that creates on one forum should be created on other in same time...(one registration for both forums). Post count should count forum1 stats + forum2 stats...

How much work are we talking about???

Arantor

In which case we're talking about modifying something like 1/3 (off the top of my head) of all the database queries inside SMF.

The reason is to achieve what you're talking about you have to use only one database's set of tables for the member. This means you have to modify any query that refers to the member table - which is a lot of them.

There were some instructions not so long ago about doing this, under "2 forums 1 database" I believe the post was called, which covered how this can be done.

The -L-

Is there anyone else here to help or just you? I wanna her more opinions...it should be like this
database:
=======================
All info and members accounts
-----------------------------------------
All important stuff and settings
-----------------------------------------
Forum data
-----------------------------------------
Forum data2
=======================

And one forum will get forum data and other one forum data 2...it shouldn't be complicate...

Arantor

Except that the info and member accounts form part of a forum's database, if you remove it from either and make it it's own database - that's even *more* work.

I'm sorry that my answers aren't what you're after but unfortunately that is the reality of the situation. SMF's tables are tightly interlinked for performance reasons, to separate them out means a lot of changes, as it's not something SMF was designed for.

The -L-

Pff...then forget it...
...is it possible to stop just one subforum from being listed on forum board?? And still can be accessed via link???

Arantor

Sure. I documented how to do it in http://www.simplemachines.org/community/index.php?topic=336590.msg2259484#msg2259484 - it's a small code change to Subs-BoardIndex.php.

The -L-

Oh damn i`m confused...
QuoteIt will show boards 44 and 45 on the main page (and category 6 as that's the category they're in, presumably) but should display nothing else.
I don`t need to show i need it to hide :DDD

Arantor

The user has the same situation. They wanted to hide all but boards 44 and 45.

What boards do you want to hide/show? I can talk you through the changes necessary for that.

The -L-

I want to hide just one board...lets say its board=31.0...

Arantor

#32
You need to follow the tip in this page first, to add a variable to index.php. They call it $settings['is_board_index'], though in reality it should really be $context['is_board_index'] as I've used here.

Then find:
WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
)


Replace with:
WHERE ' . ($context['is_board_index'] ? 'b.id_board NOT IN (31) AND ' : '') . '{query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
)

The -L-

So should it be:

$settings['is_board_index'] = true;

Or

$context['is_board_index'] = true;
??

Arantor

The tip says $settings, as per my comment it should really be $context as that's what my code uses (and $context is the proper home for it given SMF's coding structure)

The -L-

My subs-boardindex.php is as i see a little different...take a look,i searched "child_level' => $boardIndexOptions['base_level']" in my file and found just this:

Quote// Find all boards and categories, as well as related information.  This will be sorted by the natural order of boards and categories, which we control.
   $result_boards = $smcFunc['db_query']('boardindex_fetch_boards', '
      SELECT' . ($boardIndexOptions['include_categories'] ? '
         c.id_cat, c.name AS cat_name,' : '') . '
         b.id_board, b.name AS board_name, b.description,
         CASE WHEN b.redirect != {string:blank_string} THEN 1 ELSE 0 END AS is_redirect,
         b.num_posts, b.num_topics, b.unapproved_posts, b.unapproved_topics, b.id_parent,
         IFNULL(m.poster_time, 0) AS poster_time, IFNULL(mem.member_name, m.poster_name) AS poster_name,
         m.subject, m.id_topic, IFNULL(mem.real_name, m.poster_name) AS real_name,
         ' . ($user_info['is_guest'] ? ' 1 AS is_read, 0 AS new_from,' : '
         (IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read, IFNULL(lb.id_msg, -1) + 1 AS new_from,' . ($boardIndexOptions['include_categories'] ? '
         c.can_collapse, IFNULL(cc.id_member, 0) AS is_collapsed,' : '')) . '
         IFNULL(mem.id_member, 0) AS id_member, m.id_msg,
         IFNULL(mods_mem.id_member, 0) AS id_moderator, mods_mem.real_name AS mod_real_name
      FROM {db_prefix}boards AS b' . ($boardIndexOptions['include_categories'] ? '
         LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' : '') . '
         LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = b.id_last_msg)
         LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . ($user_info['is_guest'] ? '' : '
         LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})' . ($boardIndexOptions['include_categories'] ? '
         LEFT JOIN {db_prefix}collapsed_categories AS cc ON (cc.id_cat = c.id_cat AND cc.id_member = {int:current_member})' : '')) . '
         LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board)
         LEFT JOIN {db_prefix}members AS mods_mem ON (mods_mem.id_member = mods.id_member)
      WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
         AND b.child_level >= {int:child_level}') : '
         AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
      array(
         'current_member' => $user_info['id'],
         'child_level' => $boardIndexOptions['base_level'],
         'blank_string' => '',
      )
   );

Now i have no idea where to add/replace...:/

Arantor

#36
Change:
WHERE {query_see_board}'

Into:
WHERE ' . (!empty($context['is_board_index'] && $context['is_board_index']) ? 'b.id_board NOT IN (31) AND ' : '') . '{query_see_board}'

The -L-

I did what you told me to and i got this error:

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ')' in /nfs/c02/h10/mnt/30579/domains/forum-racunara.com/html/forum/Sources/Subs-BoardIndex.php on line 74

Arantor

This is what I get for coding at 2am, I miss brackets when I shouldn't, I'm sorry.

WHERE ' . ((!empty($context['is_board_index']) && $context['is_board_index']) ? 'b.id_board NOT IN (31) AND ' : '') . '{query_see_board}'

The -L-

Not a problem...i hope that this time it works ;)

Advertisement: