网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2   IP: 153.99.80.189
Old 2016-08-17, 12:37 PM
Uniopolis Uniopolis is offline
初级会员
 
Join Date: 2010-01-28
Posts: 1
Uniopolis 现在声名狼藉
Default

You can open two connections. Use one to read from the source server, the other two insert into the destination server. Use the ON DUPLICATE KEY IGNORE option to prevent errors when you try to overwrite existing rows, so it only inserts the missing rows.

Code:
$pdo1 = new PDO('mysql:host=server1;dbname=xxx', $username1, $password1);
$pdo2 = new PDO('mysql:host=servrer2; dbname=xxx', $username2, $password2);

$insert_stmt = $pdo2->prepare("INSERT INTO yourTable (col1, col2, col3, ...) VALUES (:col1, :col2, :col3, ...) ON DUPLICATE KEY IGNORE");
$select_results = $pdo1->query("SELECT * FROM yourTable");
while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) {
    $insert_stmt->execute($row);
}
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zen Cart 常用SQL命令 Renton ZenCart 0 2015-09-29 04:45 AM
Simple Steps to Change Your Table Prefix in WordPress Abby WordPress 0 2014-04-14 03:40 PM
How to Transfer Files/Backup from Server to Server topvip 服务器环境搭建 0 2010-10-20 12:02 AM
SQL Server导出导入数据方法 topvip 服务器环境搭建 0 2009-05-06 11:04 AM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 09:12 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.