Wordpress:是否可以将 $wpdb 类连接到其他数据库? [英] Wordpress : is it possible to connect $wpdb class into other database?

查看:28
本文介绍了Wordpress:是否可以将 $wpdb 类连接到其他数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该问题仅与 wordpress 编码有关.如果可能,代码解决方案可以在 wordpress 博客中使用.

the question is related to wordpress coding only. If it possible, the code solution is able to use inside a wordpress blog.

$wpdb 仅适用于在 wp-config 中声明的数据库.那么可以克隆$wpdb然后使用克隆来访问不同的数据库吗?

$wpdb is only work with database that been declare in wp-config. So it possible to clone $wpdb then use the clone to access different database?

推荐答案

您可以只创建一个新实例:

You can just create a new instance:

$db2 = new wpdb('root','root','test','localhost');

这篇关于Wordpress:是否可以将 $wpdb 类连接到其他数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆