我可以使用PHP / mySQL从Wordpress中查询其他数据库吗?
问题描述:
I have a site that is a mix of Wordpress and other PHP pages. Can I query the other database and have the results show within Wordpress?
我的网站是Wordpress和其他PHP页面的混合体。 我可以查询其他数据库并将结果显示在Wordpress中吗? p> div>
答
Yes you can since Wordpress is written in PHP, and PHP allows you to use whatever database you want.
答
Late to the party, but if you're willing to add stuff to the wp-includes/wp-db.php file you can query those other databases using the $wpdb object.
Specifically, you need to add a var:
/**
* WordPress Term Relationships table
*
* @since 2.3.0
* @access public
* @var string
*/
var $term_relationships;
and add your database name to this:
var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options','postmeta', 'terms', 'term_taxonomy', 'term_relationships');