Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 01-17-2009, 10:29 PM
Coume Coume is offline
 
Join Date: Jan 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Question Mysql question - Offset a value?

Hello,

** I posted this on vbulletin.com but now that I found out about this modification site, I guess here is the right place to post...

I just purchased a vbulletin licence to convert my phpbb forums to a vbulletin one.

Currently, I run 2 boards an English http://www.mythtvtalk.com/forum/ and a German http://de.mythtvtalk.com/forum/ one that share the same user databases, etc. I was pretty happy with this tweak at the time but now, it proves to be very difficult to merge them to create a single vbulletin one...

Anyway, I have a phpbb table with the following columns:
Code:
topic_id
forum_id
topic_title
topic_poster
topic_time
topic_views
topic_replies
topic_status
topic_vote
topic_type
topic_first_post_id
topic_last_post_id
topic_moved_id
Is there a way to offset the value of the topic_id field by i.e.: 386 in all records?
Therefore if a record has a topic_id = 34 after the SQL trick it should be replaced by 420.
Quote:
topic_id = 34 -> 420
topic_id = 35 -> 421
...
topic_id = 5789 -> 6175
etc
Any idea on how to do that in MySQL?

Thanks
Ludo
Reply With Quote
  #2  
Old 01-18-2009, 03:15 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have no idea why you would need to do this... You can run multiple imports using ImpEx.
Reply With Quote
  #3  
Old 01-18-2009, 08:08 AM
Coume Coume is offline
 
Join Date: Jan 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for answering.

btw, I am currently working in a test environment, I can't afford to mess up with my site and data

Strange in the email notification I can see:
Quote:
UPDATE tablename
SET topic_id = topic_id + 386 Remember, backup first!
but I can't see it reading your post, did you delete this bit?

As my several thousands of de/german and www have similar post_id as they were stored in different tables, I need to offset the german ones by the amount of www ones available to avoid having the German ones overriding the www ones.
Quote:
www table
post_id = 1
post_id = 2
....
post_id = 125 894
post_id = 125 895
de table
post_id = 1
post_id = 2
....
post_id = 6 704
post_id = 6 705
If I merge the two, the www's post from 1 to 6 705 would get replaced by the German ones, no?

In addition, I also need to update the forum_id as the forum_id =4 on www and on de link to different forums (i.e.: general questions in English and General questions in German), if I merge the two tables without any tweaking when importing the posts, they will all be linked to the wrong forum. So I need to create first, new forums with new IDs in the www one and then replace the old german forum_ids with this new one with something like that I guess:
"UPDATE tablename
SET forum_id = 12
WHERE forum_id = 4"

Does it make sense?
Reply With Quote
  #4  
Old 01-18-2009, 08:13 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Running ImpEx first for 1 board, finalise the import, then start with the 2nd import. This should work.

I would not suggest manipulating data unless you are absolutly sure it si the correct way to do this.
Reply With Quote
  #5  
Old 01-18-2009, 08:25 AM
Coume Coume is offline
 
Join Date: Jan 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Erm, ok.

Let me try that now as I'm in a test environment.
Reply With Quote
  #6  
Old 01-18-2009, 09:49 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Coume View Post
but I can't see it reading your post, did you delete this bit?
Yes, I did, because I figured that you were trying to do multiple imports, and this is already supported by ImpEx.
Reply With Quote
  #7  
Old 01-18-2009, 10:23 AM
Coume Coume is offline
 
Join Date: Jan 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, so I have been playing with the multiple imports and it seems to work.

I have some weird behaviour (i.e.: Some very old post from a user become posted under his name, but not linked to a new account created at a later stage by the import?) but overall it works well.

I also have the number of posts and threads that shows correctly in the stats but not the amount of users :?
Quote:
Threads: 10,639, Posts: 43,173, Members: 0, Active Members: 0
Welcome to our newest member, a
Reply With Quote
  #8  
Old 01-18-2009, 11:02 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make sure you have updated all counters as described in the ImpEx Manual after the import.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:16 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04799 seconds
  • Memory Usage 2,226KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete