News:

Join the Facebook Fan Page.

Main Menu

Double database

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

Previous topic - Next topic

The -L-

Hello...could you make me this little clearer :D

I have a forum with its database of course. I want to make another forum on my host that will have SAME database BUT a copy of it...so ALL topic,posts and members to be the same. BUT i want to erase some topic witch is un needed on second one...but i want to keep them on original forum...help me with this...

Like:
1.Original Database (Untouched)
+
2.Copy Of Database (edited)

Kill Em All

I'm actually in the process of doing this same thing. What I'm doing is creating back ups of my current database then uploading the tables to a new database. Having the same database on the same server can cause trouble between both of them.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

The -L-

If names are different then it shouldn`t be a problem and if i edit posts and merge topics then it wont be the same...

So any answers?

Kill Em All

As long as the names of the two databases are different. Correct.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

The -L-

Ok now that we know all that can you make me clealer all this...i mean how to make copy of database and change its name...(i know how to do backup but idk if its the same...) and how to establish it on other forum...:d

Kill Em All

Well what I did was copy all my current SMF files to a new directory. I backed up the database, changed the name a little. Uploaded my database, using cpanel. Then I uploaded repair_settings.php to that directory, changed the needed info such as the database info, directories... Look at these links for any help you need.
What is repair_settings.php?
How do I restore a database backup?
How do I backup my database?

That should be all you need really.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

The -L-

Now that i think a bit...i need to all my members be members on both forums...cause i dont want for guests to see links and i want for moderators to moderate (and registration would be needed twice -.-). So i need those databases connected witch is i guess impossible......

Idk can i make hidden category on forum that can be seen just via link???
Or something similar?

Arantor

What are you trying to achieve, exactly?

If you want two forums with the same members, but different boards, you'll have to get into the realms of merging databases and modifying the code - which is no small task.

The -L-

I basically want to split board at 2 forums... but i want it to have same database as when someone registers on one he is automatically registered at other one...

Or if there is simpler solution...

Arantor

There are various solutions.

I'm still not clear on the necessity of the divide - depending on what you're trying to achieve there are many different ways to do it.

The -L-

Like what?

I just wanna separate two categories into 2 same forums...(ofc if its possible)

Arantor

Oh, it's possible. But I'm trying to establish the logic behind it. Separating two categories into two forums that utilise the same logins is a HUGE amount of work, especially if you want to keep certain divides between them such as independent post counts, plus things like single-sign on (i.e. login on one logs you in on both)

Remember, you can have different themes at board level, so it would be possible to make it look and feel like two distinct sites whilst having only one structure in place.

And if you have these two across two domains, it suddenly gets even more complex. Not to mention if the two are on different servers.

The -L-

No no no,its on one domain xD

Is it possible to make hidden category or sub forum on forum? (And access can be established just over link)
And is it possible to that hidden cat/sub has its own nav bar (different then the others)?

Arantor

You can hide category/forum/subforum based on usergroup (but that limits access)

If you just want to hide it that's going to be a custom modification to BoardIndex.php.

As for custom navbar, that's easy; you can assign a different theme (which can include navbar) to every board if you like.

The -L-

QuoteYou can hide category/forum/subforum based on usergroup (but that limits access)
Can i do this without limiting access? Like to subforum dont get listed and still can be accessed via something like
www.forum.com/index.php?topic=336177.new;topicseen#new

??? :P

Arantor

Quote from: Arantor on September 13, 2009, 09:52:52 AM
If you just want to hide it that's going to be a custom modification to BoardIndex.php.

The -L-

Hmm...can you show me more info...like what to search for and with what to replace in code...

Arantor

Not really because it's not a simple find/replace job.

It's a series of changes depending on the number and types of boards, possibly also changes to BoardIndex.template.php too.

The -L-

Nah then i wouldn`t mess with it...

The -L-

My good friend is mysql and php expert he runs really great sites...he told me that its possible to do what i want he told that database is file that contains everything from user accounts to board data and all info and settings...he told that in forum index board file there is command that calls a list of boards out from my database witch part is named "forum"...he told that if i split "forum" part of database and name the other half "forum2" i could call it from other forum so original forum use just "forum" part of database and other forum i want to make would use "forum2" part of database...

Could this be done?

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 ;)

The -L-

#40
hmm it doesnot work....i made a new subforum with id=111.0

so the new code would be:
WHERE ' . ((!empty($context['is_board_index']) && $context['is_board_index']) ? 'b.id_board NOT IN (111) AND ' : '') . '{query_see_board}'

???

Arantor

That would be the code - but it's not hiding it?

The -L-

nope its not hiding it...:/
Even when i logout... its still there :/

Arantor

Yeah, the guy in the other thread is having the same problem. And right now I don't know why since that should do it.

The -L-

What about this?

'visible_boards' => array(44,45),

In my case it should be hide_boards but anyway we didn`t put this part of the code...

I read whole tread... Still haven't find an answer to this problem...:/

Arantor

That code is geared to the other person's problem (they want to only show those two boards).

I'm still trying to figure out what's going on with this on my test install.

The -L-

Sorry if i sound rude or something i really haven't meant anything bad. My English is as you can see bad so i may leave a bad mark behind me. I apologize for that...:/

The -L-

Anything new about this problem???

Arantor

I haven't had chance to test this properly in the last day or so, but I haven't found a solution to it :(

The -L-


Arantor

I didn't say that - I've just been very busy with other things to dig into this properly.

The -L-

When you find some free time please look into this,and let me know if you find out something :/

Dzonny


The -L-

Hehe,thanks it works.

Topic finally solved :D

Dzonny

You're welcome...

I've marked topic as solved now...

Regards.

Advertisement: