【问题标题】:Can I query other databases from within Wordpress using PHP/mySQL?我可以使用 PHP/mySQL 从 Wordpress 中查询其他数据库吗?
【发布时间】:2010-11-19 02:35:51
【问题描述】:

我有一个混合了 Wordpress 和其他 PHP 页面的网站。我可以查询其他数据库并将结果显示在 Wordpress 中吗?

【问题讨论】:

    标签: php mysql database wordpress


    【解决方案1】:

    是的,你可以,因为 Wordpress 是用 PHP 编写的,而且 PHP 允许你使用任何你想要的数据库。

    【讨论】:

      【解决方案2】:

      迟到了,但如果您愿意在 wp-includes/wp-db.php 文件中添加内容,您可以使用 $wpdb 对象查询其他数据库。

      具体来说,你需要添加一个var:

      /**
           * WordPress Term Relationships table
           *
           * @since 2.3.0
           * @access public
           * @var string
           */
           var $term_relationships;
      

      并将您的数据库名称添加到此:

      var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options','postmeta', 'terms', 'term_taxonomy', 'term_relationships');   
      

      【讨论】:

        猜你喜欢
        • 2023-03-17
        • 2021-11-28
        • 1970-01-01
        • 2012-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-02
        • 1970-01-01
        相关资源
        最近更新 更多