Previous Thread
Next Thread
Print Thread
Rate Thread
#263464 11/24/2003 11:19 PM
Joined: Mar 2001
Posts: 13
Newbie
Newbie
Joined: Mar 2001
Posts: 13
I'm trying to do something that seems on the outside like it would be simple. I need to archive some posts off of my main database and onto another one to try and speed things up for my forums. All I really need for it to do is to copy old posts onto another database. I can delete them manually once they are copied over. I don't have much experience writing php code. I do have some in VB and Lotus script. I have this so far: [] <?php require_once('Connections/db6.php');

mysql_select_db($database_db6, $db6);
$query_Recordset3 = "SELECT * FROM w3t_Posts WHERE B_Number = [$i]";
$Recordset3 = mysql_query($query_Recordset3, $db6) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);


require_once('Connections/db1.php');
mysql_select_db($database_db1, $db1);
$query_insert = "
INSERT INTO w3t_Posts (B_Board,B_Parent,B_Main,B_Posted,B_Last_Post,B_IP,B_Subject,B_Body,B_Kept,B_Status,B_Approved,B_Icon,B_Reged,B_Poll,B_Replies,B_Topic,B_Convert,B_PosterId,B_AnonName,B_Sticky,B_ParentUser)
VALUES ('$Board_q','$Parent','$Main','$date','$date','$IP_q','$Subject_q','$BodySig','$Kept_q','$PStatus_q','$Approved_q','$Icon_q','$Reged_q','$PollName','0','$Topic','$convert_q','$posterid','$AnonName_q','0','$ParentUser')
";
$insert = mysql_query($query_insert, $db1) or die(mysql_error());

?> [/]

I've pirated some of this. Anyway, my main plan is to step through this using a do while loop and incrementing variable $i. Can I just set the variable $Board_q = B_Board etc.? I don't have any idea how arrays really work in php. Can I just load all of the posts I need into an array and move them at once instead of stepping through one record at a time? There are about 150,000 posts I need to move. Thanks for any help. I have some PHP books on the way but I would like to go ahead and get this working.


[:"blue"]Kristina[/]
Sponsored Links
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Kristina,

If the two databases are in the same MySQL server then what you can do is:

INSERT INTO Database1.w3t_Posts (B_Board,B_Parent,B_Main,B_Posted,B_Last_Post,B_IP,B_Subject,B_Body,B_Kept,B_Status,B_Approved,B_Icon,B_Reged,B_Poll,B_Replies,B_Topic,B_Convert,B_PosterId,B_AnonName,B_Sticky,B_ParentUser)
SELECT B_Board,B_Parent,B_Main,B_Posted,B_Last_Post,B_IP,B_Subject,B_Body,B_Kept,B_Status,B_Approved,B_Icon,B_Reged,B_Poll,B_Replies,B_Topic,B_Convert,B_PosterId,B_AnonName,B_Sticky,B_ParentUser
FROM Database2.w3t_Posts

That will copy all the posts from one database/table to another. Now since you said that there are 150K records you will either need a tool like phpMyAdmin or direct shell access to your server.

The trick with moving posts and threads is that they are linked and you cannot just move one and get over with it, you will need to move its "children" i.e. the replies.

Also you might want to have a look at JoshPet's Mass Threads Move modification to make your life easier. This modification will move the threads from one board to another for archiving but if you see it you might get a better understanding on what is needed to move posts.

Finally what you can do is take a mysqldump of the currend database, restore it somewhere else (another database) and then delete the old threads.

Loading all the posts in an array is not a good idea since you will grab all the resources from the server - for sure.

I hope this helps


Nikos

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,575
Posts293,932
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,835
Greg Hard 4,625
Top Posters(30 Days)
Gizmo 2
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)