Wordpress dbdelta:没有错误,没有结果,没有响应

时间:2013-07-26 06:51:12

标签: php database wordpress

我正在尝试创建一个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做任何事情,我或许可以自己做。

0 个答案:

没有答案