PHP merge discuz user script method, php merge discuz script
This example describes how to merge discuz user scripts in PHP. Share it with you for your reference. The details are as follows:
A few days ago, I met a project that needs to merge two discuz jobs. One project has a user level of around 0.12 million, and the other is 10 thousand 8. Needless to say, it definitely throws 10 thousand 8, leaving 0.12 million. At first, I felt that it was not easy to handle. Data Tables were all associated. I registered a new user and added records to eight tables. I haven't seen whether other tables have the possibility of modifying records. At that time, I thought that at half past one, I couldn't understand those tables. I searched for them and found the discuz tool. but I can only export less than 0.1 million, so I can only try it myself. Later I thought about how to insert a record directly in the key table, other tables may automatically complete the relevant data during user operations, so they try to export the original 10 thousand users, then I wrote a PHP script to directly write the 10 thousand users to the memeber TABLE OF THE uncenter. The test is OK. Unfortunately, the user points are missing, but the user name and password are retained.
Key steps:
1. Export the uncenter member database of the system to be replaced as an SQL file.
2. Run the script.
Disclaimer: This script only provides ideas. Back up data before using it. Data loss is irrelevant to the author. (Simple code, Do not spray)
Set_time_limit (0); $ link = mysql_connect ('localhost', 'ngjc', 'ohft6yhhyvt5 ') or die ('could not connect :'. mysql_error (); echo 'connected successfully '; mysql_select_db ('ngjc') or die ('could not select database'); require "SQL. php "; // The exported SQL File $ arrayerr = array (); $ oknum = 0; $ errnum = 0; mysql_query (" SET NAMES utf8 "); foreach ($ sqlarr as $ SQL) {if (! Mysql_query ($ SQL) {$ arrayerr [] = $ SQL; $ errnum ++;} else {$ oknum ++;} echo "<pre> OK: $ oknum <br> errornum: $ errnum <br> error: <br> "; print_r ($ arrayerr); mysql_close ($ link );
I hope this article will help you with php programming.