diff options
author | Nils Adermann <naderman@naderman.de> | 2007-02-16 23:06:14 +0000 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2007-02-16 23:06:14 +0000 |
commit | 72594577015eb9464aa0916c20ed9f8b41f6dfd6 (patch) | |
tree | 27b1b5b27e8f7c28cf8972e83e68dea94537d0f3 /phpBB/includes/functions_convert.php | |
parent | ec9a091669e37b799c0fa66f81ccca1ca434afdb (diff) | |
download | forums-72594577015eb9464aa0916c20ed9f8b41f6dfd6.tar forums-72594577015eb9464aa0916c20ed9f8b41f6dfd6.tar.gz forums-72594577015eb9464aa0916c20ed9f8b41f6dfd6.tar.bz2 forums-72594577015eb9464aa0916c20ed9f8b41f6dfd6.tar.xz forums-72594577015eb9464aa0916c20ed9f8b41f6dfd6.zip |
- allow converting from one database to another, no need for tables to be in one database anylonger (this also allows switching from one DBMS that was used with phpBB2 to another DBMS supported by phpBB3 including new systems available in Olympus only)
- abstracted some installation code that is now relevant to converting as well into functions_install.php (mostly DBMS selection related)
- fixed a weird smiley path problem, no idea why nobody else noticed this, maybe my fix was incorrect?
- forgot to commit a file last time
git-svn-id: file:///svn/phpbb/trunk@6995 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_convert.php')
-rw-r--r-- | phpBB/includes/functions_convert.php | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 6df29fc0f4..4244645af8 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -558,7 +558,7 @@ function _import_check($config_var, $source, $use_target) 'relative_path' => (empty($convert->convertor['source_path_absolute'])) ? true : false, ); - $target = $config[$config_var] . '/' . basename(($use_target === false) ? $source : $use_target); + $target = '../' . $config[$config_var] . '/' . basename(($use_target === false) ? $source : $use_target); if (!empty($convert->convertor[$config_var]) && strpos($source, $convert->convertor[$config_var]) !== 0) { @@ -1068,7 +1068,7 @@ function add_user_group($group_id, $user_id, $group_leader=false) */ function user_group_auth($group, $select_query) { - global $convert, $phpbb_root_path, $config, $user, $db; + global $convert, $phpbb_root_path, $config, $user, $db, $src_db, $same_db; if (!in_array($group, array('guests', 'registered', 'registered_coppa', 'global_moderators', 'administrators', 'bots'))) { @@ -1089,9 +1089,33 @@ function user_group_auth($group, $select_query) return; } - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' (user_id, group_id, user_pending) - ' . str_replace('{' . strtoupper($group) . '}', $group_id . ', 0', $select_query); - $db->sql_query($sql); + if ($same_db) + { + $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' (user_id, group_id, user_pending) + ' . str_replace('{' . strtoupper($group) . '}', $group_id . ', 0', $select_query); + $db->sql_query($sql); + } + else + { + $result = $src_db->sql_query(str_replace('{' . strtoupper($group) . '}', $group_id . ', 0', $select_query)); + while ($row = $src_db->sql_fetchrow($result)) + { + // make sure it's exactly 3 ints that were returned + $data = array(); + reset($row); + for ($i = 0; $i < 3; $i++) + { + $data[] = (int) current($row); + next($row); + } + + // this might become quite a lot of INSERTS unfortunately + $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' (user_id, group_id, user_pending) + VALUES (' . implode(', ', $data) . ')'; + $db->sql_query($sql); + } + $src_db->sql_freeresult($result); + } } /** @@ -1109,14 +1133,19 @@ function get_config() return $convert_config; } - global $db, $phpbb_root_path, $config; + global $src_db, $same_db, $phpbb_root_path, $config; global $convert; if ($convert->config_schema['table_format'] != 'file') { + if ($convert->mysql_convert && $same_db) + { + $src_db->sql_query("SET NAMES 'binary'"); + } + $sql = 'SELECT * FROM ' . $convert->src_table_prefix . $convert->config_schema['table_name']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); + $result = $src_db->sql_query($sql); + $row = $src_db->sql_fetchrow($result); if (!$row) { @@ -1133,8 +1162,13 @@ function get_config() { $convert_config[$row[$key]] = $row[$val]; } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); + while ($row = $src_db->sql_fetchrow($result)); + $src_db->sql_freeresult($result); + + if ($convert->mysql_convert && $same_db) + { + $src_db->sql_query("SET NAMES 'utf8'"); + } } else if ($convert->config_schema['table_format'] == 'file') { @@ -1153,6 +1187,10 @@ function get_config() else { $convert_config = $row; + if ($convert->mysql_convert && $same_db) + { + $src_db->sql_query("SET NAMES 'utf8'"); + } } if (!sizeof($convert_config)) |