vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Question Mysql question - Offset a value? (https://vborg.vbsupport.ru/showthread.php?t=202178)

Coume 01-17-2009 10:29 PM

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

Dismounted 01-18-2009 03:15 AM

I have no idea why you would need to do this... You can run multiple imports using ImpEx.

Coume 01-18-2009 08:08 AM

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?

Marco van Herwaarden 01-18-2009 08:13 AM

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.

Coume 01-18-2009 08:25 AM

Erm, ok.

Let me try that now as I'm in a test environment.

Dismounted 01-18-2009 09:49 AM

Quote:

Originally Posted by Coume (Post 1716601)
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.

Coume 01-18-2009 10:23 AM

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

Marco van Herwaarden 01-18-2009 11:02 AM

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


All times are GMT. The time now is 01:00 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01133 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete