Can you split phpBB's Database?
-----
| Author | Message | |
|---|---|---|
|
DarkScythe |
||
| Fri Sep 15, 2006 9:19 pm Post subject: re: Can you split phpBB's Database? | ||
|
Gah, I hate debugging. lol
Inserted the registration code into EE's registration page and I got this error, although not as concise as phpBB's. Code: Fatal error: Call to a member function on a non-object in /home/********/public_html/expeng/system/modules/member/mod.member_register.php on line 546 Line 546 would be.. Code: if ( !($result = $db->sql_query($sql)) )
It's from the first SQL check to grab the user_id for phpBB Code: // ---------------------------------------
// Insert phpBB-Specific Registration Code // --------------------------------------- // Generate Proper user_id, since it differs from EE's member_id $sql = "SELECT MAX(user_id) AS total FROM ********_forumsDB.phpbb_users"; (line 546 ->) if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } if ( !($row = $db->sql_fetchrow($result)) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } $user_id = $row['total'] + 1; Time to google.. I'm not quite sure what the member function on a non-object means though :/ |
||
|
DarkScythe |
||
| Fri Sep 15, 2006 9:39 pm Post subject: re: Can you split phpBB's Database? | ||
|
Hmm, okay this is kind of dumb..
I *think* it may be the $db calls, at least that's what my current googling is telling me. I took a long shot and changed every instance of $db to $DB (upper case) since one of the links I read said $db needed to be declared. I guess variables are case-sensitive, because EE uses $DB just fine. In any case, after that, it complained about sql_query not being defined, and I noticed that the EE code *right above* my insertion point says Code: $DB->query($DB->insert_string('exp_member_homepage', array('member_id' => $member_id)));
So I renamed all sql_query to just query, and it got rid of that error. Next it complained about sql_fetchrow.. I'm not sure how to proceed past this now, because I'm trying to find out where it's defined in the phpBB files with no success. Is this part even required? Syntax is killing me.. lol EDIT: I found it, it was defined in the mysql.php file in the /db/ folder. Code: function sql_fetchrow($query_id = 0)
{ if(!$query_id) { $query_id = $this->query_result; } if($query_id) { $this->row[$query_id] = @mysql_fetch_array($query_id); return $this->row[$query_id]; } else { return false; } Should I just paste this into the registration code before it uses sql_fetchrow? Or is the line not important and I should just delete the thing.. |
||
|
Thoul |
||
| Sat Sep 16, 2006 12:27 pm Post subject: re: Can you split phpBB's Database? | ||
|
All the $db-> stuff in phpBB's code is specific to phpBB and generally won't work with EE (unless you do an include() to pull mysql.php and establish a second database connection - big headache).
EE has something similar, $DB, which you've found. I guess $DB->query is the counterpart to phpBB's $db->sql_query. There should also be a counterpart to $db->sql_fetchrow. If you can't find it, you should be able to use mysql_fetch_array, like so: Code: // ---------------------------------------
// Insert phpBB-Specific Registration Code // --------------------------------------- // Generate Proper user_id, since it differs from EE's member_id $sql = "SELECT MAX(user_id) AS total FROM ********_forumsDB.phpbb_users"; (line 546 ->) if ( !($result = $DB->query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } if ( !($row = @mysql_fetch_array($result)) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } $user_id = $row['total'] + 1; It may also complain about message_die in the event of another error. message_die is also specific to phpBB. I'm not sure what the EE analog would be, but you could use something like this instead: Code: die('Could not obtain next user_id information' . '<br>' . __LINE__ . '<br>' . __FILE__ . '<br>' . $sql);
|
||
|
DarkScythe |
||
| Sat Sep 16, 2006 4:28 pm Post subject: re: Can you split phpBB's Database? | ||
|
Thanks, I'm trying to find out if EE has any equivalent to phpBB's sql_fetchrow(), but at first glance it doesn't look like EE really outputs many errors the way phpBB does. I tried using @mysql_fetch_array, but it complained about an unexpected @. I removed it and complained that mysql_fetch_array() was undefined.. lol
I'm not sure if message_die would be a problem or not though, since it goes right past the first message_die without any problems, but maybe that's because there were no errors to invoke it. I found something similar to fetchrow, $query->row but it said row() wasn't defined.. argh |
||
|
DarkScythe |
||
| Wed Oct 04, 2006 3:12 pm Post subject: re: Can you split phpBB's Database? | ||
|
Wow, I know it's been a while but I'm still struggling with this lol.
Guess that's a drawback to being a novice PHP programmer I tried t get the mods working but in the end it didn't really work as I intended, but I recall an article that told you how to share the users on two different forum installs, I think I can expand that to share everything except the config table. In any case, I am still trying to work around the phpBB-registration script within EE. I tried plugging the function definition everywhere and it will not recognize it. mysql_fetch_array() does not work. EE's num_rows does not work, although I believe it's for a different purpose. Support from their forums have directed me to their developer doc's at http://eedocs.pmachine.com/development/usage/database.html However, I am struggling to understand exactly WHAT that line does. Code: $sql = "SELECT MAX(user_id) AS total FROM ********_forumsDB.phpbb_users"; if ( !($result = $DB->query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } if ( !($row = $DB->sql_fetchrow($result)) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } $user_id = $row['total'] + 1; If I can see this correctly, it starts off with an SQL query to select the highest user_id value from the table specified. The next two are for what to do if an error arises. If the result is the same query(?) it evaluates false because of the negation (!) in front of it and produces an error message because it can't access the database.. Next, if the sql query is not the same as it was entered, because it pulled an actual result, but the row...doesn't exist? What? I have no idea what it is trying to do with sql_fetchrow lol. God this is painful |
||
|
Thoul |
||
| Wed Oct 04, 2006 4:05 pm Post subject: re: Can you split phpBB's Database? | ||
|
Ok, let's see if I can explain it.
It starts off with the query: Code: $sql = "SELECT MAX(user_id) AS total
FROM ********_forumsDB.phpbb_users"; Then ($result = $DB->query($sql) runs the query and gets the result. If the query fails to run (the table doesn't exist or some other nasty thing), then an error message is triggered. Code: if ( !($result = $DB->query($sql)) )
{ message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } If the query runs okay, ($row = $DB->sql_fetchrow($result) tries to get the actual information located by the query and store this as $row. If it can't (very rare!), another error is triggered. Code: if ( !($row = $DB->sql_fetchrow($result)) )
{ message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } Now, based on that link you posted, it looks like EE does the sql_fetchrow stuff internally and you can skip that. So for the code you're plugging into EE, you should be able to replace all this: Code: if ( !($row = $DB->sql_fetchrow($result)) )
{ message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } $user_id = $row['total'] + 1; With: Code: $user_id = $result->row['total'] + 1;
|
||
|
DarkScythe |
||
| Wed Oct 04, 2006 6:39 pm Post subject: | ||
|
lol Thanks for the description, the negations always messes me up
I got a similar reply from the EE support forums, only they gave a workaround to use fetchrow, they didn't seem to hint that it was done in the background though. Code: global $DB; $query = $DB->query("SELECT MAX(user_id) AS total FROM prefix_forumsDB.phpbb_users"); if ($query->num_rows == 0) { ...error handling... } $user_id = $query->row['total'] + 1; Was the snippet they provided, which does use num_rows, just in the correct way, as opposed to how I was trying to use it lol In any case, I replaced what you said to replace and the error disappeared.. except for a little syntax. Code: MySQL ERROR: Error Number: 1064 Description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''steel@darkscythe.com)' at line 2 Query: INSERT INTO ********_forumsDB.phpbb_users (user_id, user_active, username, user_password, user_regdate, user_style, user_lang, user_email) VALUES (7, 1, 'SpecialTest2', '1c58bd92003bbaa0538e249fff6ee19a270dec5f', 1160001842, 1, 'english', 'steel@darkscythe.com) It's obvious that there's a quote missing after the email thing, but I'm not sure what th proper way is to fix that.. I tried simply adding it but then the page wouldn't come up at all saying there were some unexpected errors or something. What I ended up doing was this: Code: $sql = "INSERT INTO ********_forumsDB.phpbb_users (user_id, user_active, username, user_password, user_regdate, user_style, user_lang, user_email) VALUES ($user_id, 1, '" . str_replace("\'", "''", $username) . "', '" . str_replace("\'", "''", $user_password) . "', " . time() . ", 1, 'english', '" . str_replace("\'", "''", $user_email) . "'" . ")"; Notice that series of quotes after email lol, it's working so far but I'm not sure if that's how you're suppsoed to do it XD HUUUUGE thanks to you though, I wouldn't have done it without all your help Now that I'm half done .. time to track down the pesky password changes hehe |
||