[英]PHP: Move data from one php database app to another on a different server
I have two php database apps on different servers. 我在不同的服务器上有两个php数据库应用程序 I would like to be able to transfer the data from a particular record from the first server to the second, with some processing inbetween to account for the differences in database schema.
我希望能够将特定记录中的数据从第一个服务器传输到第二个服务器,并在其间进行一些处理以解释数据库模式的差异。 The two servers cannot access each others databases.
这两个服务器无法访问彼此的数据库。 So the user would click a link on the record and then basically that data would be transferred over to the other server for confirmation.
因此,用户将单击记录上的链接,然后基本上将该数据传输到另一个服务器以进行确认。 I looked at a redirect with POST, but that doesn't seem to be possible.
我看了一下POST的重定向,但这似乎不可能。 Any better ways?
有更好的方法吗?
Select record on server 1 -> Process record to correct form -> transfer PHP array to server 2 -> confirmation page on server 2 选择服务器1上的记录 - >进程记录以更正表单 - >将PHP数组传输到服务器2 - >服务器2上的确认页面
If I had to do something like this, I'd take my data that needs to be processed, process it on my server (from where I take it) then serialize result and send it to another server using post method. 如果我不得不做这样的事情,我会拿出需要处理的数据,在我的服务器上处理它(从我接收它)然后序列化结果并使用post方法将其发送到另一台服务器。 Using another script unserialize and simply store in a database that runs on the second server.
使用另一个脚本反序列化并简单地存储在第二个服务器上运行的数据库中。
you can use curl as i mentioned with the help of this example 你可以使用我在这个例子的帮助下提到的卷曲
//assuming the variable that holds your record is $row
$row = array("key1" => "value1", "key2" => "value2");
$post_fields = "";
foreach($row as $key=>$field){
$post_fields .= $key . "=" . $field . "&";
}
$Curl_Session = curl_init('http://yourseconddomain.com/yourfile.php');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_exec ($Curl_Session);
curl_close ($Curl_Session);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.