Can you split phpBB's Database?


  -----  
Author Message

Thoul
Administrator

Thu Sep 07, 2006 10:28 pm   Post subject: re: Can you split phpBB's Database?
If you include the DB.table in the quotes of the query, as I did on the second post on this page, that problem should be fixed. I didn't think of it before, but that will definitely have to be in quotes because the . is a special character in PHP. Right now, PHP thinks you want to combine ********_eeDB and exp_members into one word. You really want to use ********_eeDB.exp_members, but PHP won't understand that unless it's in quotes.

Quote:

Unless I'm wrong here, shouldn't I have to close the current DB connection, or at least open a new one to access EE's DB temporarily?


That would be one way to do it, but the DB.table method should let you jump over to EE's DB for just the one query, without closing the connection.

Quote:

Also had to delete the user from thr phpBB database a couple times but now the user_id and group_id aren't the same anymore.. where else does it keep the group id thing?


Mainly in the _groups and _user_groups tables. That's all

I can recall at the moment.
 

DarkScythe
Member

Thu Sep 07, 2006 10:29 pm   Post subject: re: Can you split phpBB's Database?
Nevermind what I just said, lol

I managed to fix it. I eliminated the extra quotes around the DB.table, because PHP was parsing them rather than SQL, so the SQL query wasn't getting the hint to go check another DB.. Silly me.

I changed the code for all 3 SQL inserts and it worked.

Code:


// Insert relevant data into main membership table

         $sql = "INSERT INTO ********_eeDB.exp_members (member_id, group_id, username, screen_name, password, unique_id, email, ip_address, join_date)
            VALUES ($member_id, 5, '" . str_replace("\'", "''", $username) . "', '" . str_replace("\'", "''", $username) . "', '" . str_replace("\'", "''", $new_password) . "', '$unique_id', '" . str_replace("\'", "''", $email) . "', '$ip_address', " . time() . ")";
         if( !($result = $db->sql_query($sql)) )
         {
            message_die(GENERAL_ERROR, 'Could not insert data into exp_members table', '', __LINE__, __FILE__, $sql);
         }


edit:
darn, couple seconds late lol Super Razz

Next up, Testing on EE, then the last task.. find out all the pesky places where the user can change their password.
 

DarkScythe
Member

Sun Sep 10, 2006 7:01 pm   Post subject: re: Can you split phpBB's Database?
All right, apparently EE released a new version, so I had to doublecheck and make sure nothing registration-related was changed too much. It seems like it will be fine though, so back to coding the phpbb stuff.

I had phpbb's group_id set to its user_id because they were initially the same. However, when I did the test registrations and had to manually delete the user from the DB a couple times, I noticed the group_id kept going up, and this concerns me a little. Do you know where phpBB gets its group_id value from?
So far I only see the code as

Code:


$group_id = $db->sql_nextid();


In the interest of being as close as possible, I've currently set group_id to check for the max+1, just like with the user_id, but I'm not sure if phpbb_users_table is the right place to grab it.
 

Thoul
Administrator

Sun Sep 10, 2006 11:06 pm   Post subject: re: Can you split phpBB's Database?
For phpBB, the group id is generated when a group is inserted into the table. group_id is an autocrement field in the phpbb_groups table, so it's automatically set to max+1 whenever a new row is inserted. Then that line you post there gets the group_id that was generated, which is used elsewhere.

So, a max+1 check should work fine.
 

DarkScythe
Member

Mon Sep 11, 2006 11:03 am   Post subject: re: Can you split phpBB's Database?
Oh, so I should tell it to do the max+1 check on phpbb_groups rather than phpbb_users_table?
Or does it not make a difference, since the group_id should be the same across all tables..

Thanks again for all the help Smile
 

Thoul
Administrator

Mon Sep 11, 2006 11:32 am   Post subject: re: Can you split phpBB's Database?
I would do it on phpbb_groups. phpbb_users doesn't store the group_id itself.
 

DarkScythe
Member

Tue Sep 12, 2006 8:17 pm   Post subject: re: Can you split phpBB's Database?
Thanks, it's full steam ahead debugging the registration scripts and hunting down profile changes Smile

One problem I just thought of though. I will be hosting several different sites (on separate domains), and EE has the functionality to power multiple sites built in, but I forgot that phpBB probably wasn't designed for that.
What I mean is if I install the forum under domain1.com, users accessing it via domain2.com will see all the links as domain1.com and cause confusion.. I want to share the same exact forum across all the sites (since I'm already sharing user info) but correct the domain bit.

This is the opposite of my thread title, and I know it's possible to have 2 forum installs in the same DB sharing some tables, but is it possible for me to install twice in the phpBB DB and tell both to use the same exact tables?
That way all the data is the same, but each domain will have its own output files and the domains will be corrected..
 

Thoul
Administrator

Wed Sep 13, 2006 11:11 am   Post subject: re: Can you split phpBB's Database?
It's possible, but it may be easier to install a hack to allow the one set of forum files to work across multiple domain names. Here's one, though I haven't tried it personally:
http://www.phpbb.com/phpBB/viewtopic.php?t=222346
 

DarkScythe
Member

Wed Sep 13, 2006 12:36 pm   Post subject: re: Can you split phpBB's Database?
Thanks for the link Thoul Smile
I'm reading through it, but I'm having some trouble figuring out how it works.. It looks like any other mod -- works via a code insertion somewhere, but it seems like you need a second copy of the files (if not a second install altogether) at the other domains you want to "hook" into. If you do need a "second" forum to use the mod, wouldn't it be possibly easier to just install it multiple times using the same tables?

Unless I've read it wrong and it only requires the forum installed once and it'll automatically capture the other domains.. I know you haven't used it, so I don't really expect a solid answer, but I am a bit confused as to how it works.
Thanks again!
 

Thoul
Administrator

Wed Sep 13, 2006 5:16 pm   Post subject: re: Can you split phpBB's Database?
No, you should only need one install with that mod. Basically what it does is capture the domain name from the URL used to access the forum, then the forum will think that URL is what has been entered in the ACP configuration for the domain and path.

I took a second look at it and though I haven't used this specificly, I have used something very similar in the past. It should work well.
 

Page 4 of 5
Go to page Previous  1, 2, 3, 4, 5  Next
Display posts from previous: