gpt4 book ai didi

PHP MySQL : How to insert specific records from one db to another db different server?

转载 作者:行者123 更新时间:2023-11-29 23:38:34 24 4
gpt4 key购买 nike

db 1 表 1

  1. 姓名
  2. 多布
  3. 地址
  4. 身份证
  5. 上次更新日期

上表中的特定记录(使用where条件)必须插入或更新到不同服务器的另一个db 2表2。

最佳答案

如果只进行一次,只需在任何数据库编辑工具(例如 MySQL Workbench 或 SQLyog)中进行即可。

如果您需要经常这样做,请这样做:

  1. 与数据库 1 建立连接
  2. 从 db1 table1 中获取所有需要的记录并将它们放入数组中
  3. 关闭与 db 1 的连接并打开与 db 2 的连接
  4. 循环遍历包含记录的数组并在 db2 中插入/更新它们
  5. 关闭与 db2 的连接。

应该没那么难

关于PHP MySQL : How to insert specific records from one db to another db different server?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26292675/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com