wordpress仅包含wpdb(wpdb for ajax)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wordpress仅包含wpdb(wpdb for ajax)相关的知识,希望对你有一定的参考价值。
So, you define a couple of fake funcs and require WP database config, after this you can require wp-db.php, create new wpdb and use it independency of WP for your ajax actions.
<?php //fake funcs function is_multisite() {return true;} function apply_filters($tag, $value) { return $value; } function wp_load_translations_early() {} function __($text) { return $text; } // $doc_root = $_SERVER['DOCUMENT_ROOT']; require $doc_root . '/db-config.php'; require $doc_root . '/wp-includes/wp-db.php'; //Oh, Yeah! $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); ?>
以上是关于wordpress仅包含wpdb(wpdb for ajax)的主要内容,如果未能解决你的问题,请参考以下文章
Wordpress:wpdb->插入与 wpdb->prepare(wpdb->query("INSERT
Wordpress - $wpdb->插入 - MySQL NOW()