Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress dbdelta:无错误、无结果、无响应_Php_Database_Wordpress - Fatal编程技术网

Php Wordpress dbdelta:无错误、无结果、无响应

Php Wordpress dbdelta:无错误、无结果、无响应,php,database,wordpress,Php,Database,Wordpress,我正在尝试创建一个Wordpress插件。稍后将提供设置数据库表的代码。然而,我面临的问题与其说是一个错误,不如说是一个缺失。不管我做什么,dbdelta似乎什么也不做——wordpress不会产生任何相关的错误,至少不会给我一个错误的线索 代码是: function create_tables() { global $wpdb; $pl_nm = VSystem::$plugin_name; $create_voters = "create table if not e

我正在尝试创建一个Wordpress插件。稍后将提供设置数据库表的代码。然而,我面临的问题与其说是一个错误,不如说是一个缺失。不管我做什么,dbdelta似乎什么也不做——wordpress不会产生任何相关的错误,至少不会给我一个错误的线索

代码是:

function create_tables()
{
    global $wpdb;
    $pl_nm = VSystem::$plugin_name;
    $create_voters = "create table if not exists {$wpdb->prefix}{$pl_nm}_voters(
        ID bigint(20) unsigned auto_increment,
        user_id bigint(20) unsigned not null,
        primary key  (ID),
        foreign key (user_id) references {$wpdb->prefix}users(ID)
    );";

    $create_links = "create table if not exists {$wpdb->prefix}{$pl_nm}_links(
        ID bigint(20) unsigned auto_increment,
        product bigint(20) unsigned,
        name varchar(256) not null,
        url varchar(512) not null,
        description text,
        posted datetime,
        poster bigint(20) unsigned not null,
        primary key  (ID),
        foreign key (poster) references {$wpdb->prefix}users(ID)
    );";

    $create_votes = "create table if not exists {$wpdb->prefix}{$pl_nm}_votes(
        ID bigint(20) unsigned auto_increment,
        link_id bigint(20) unsigned not null,
        voter_id bigint(20) unsigned not null,
        choice int not null,
        primary key  (ID),
        foreign key (link_id) references {$wpdb->prefix}{$pl_nm}_links(ID),
        foreign key (voter_id) references {$wpdb->prefix}users(ID)
    );";
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $create_voters );
    dbDelta( $create_links );
    dbDelta( $create_votes );
    dbDelta("asdasdsadsad");
    //wp_die("{$wpdb->prefix}{$pl_nm}");



    add_option('db_version', VSystem::$defaults['db_version']);
}

function vsystem_install()
{
    create_tables();
}
现在我知道这个函数正在被调用,至少是因为取消对wp_die命令的注释是按照它应该的方式进行的。我能得到任何帮助吗

    dbDelta("asdasdsadsad");

即使这样似乎也不会产生任何反应。如果有人能告诉我如何让dbdelta做任何事情,我也许可以自己做这件事。

在wp-config.php中,您是否将wp_DEBUG设置为true?ie定义'WP_DEBUG',为true,否则您将无法看到任何错误。所以对于那些不幸再次遇到这个问题的人来说。1外键似乎有问题-但嘿,它只是一个爱好者级的网站CMS,所以我怀疑引用完整性是一个大问题。2创建的表格应大写。我不知道为什么,但这样做使查询工作,除了截断外键外,没有其他更改。-3这个函数和Wordpress通常不习惯给出简洁的错误报告——如果有的话@Ahmad我会研究一下。sql语法不必大写,只是没有打开错误报告,我想:没有。这两个问题是独立的。当然,可能会发生很多事情。但是我没有任何关于调试的东西。或者我的代码。我只是将sql大写,看看是否会发生任何事情。@Yuma:你能在答案中包含你的新代码并接受它吗?一、 其他人可能真的很想看到截断的外键语法。