WordPress - 从自己的插件保存数据



我自己的wordpress插件生成了一个文件的数据:

文件名|创建者|日期

    This is my filename|Max Mustermann|20.11.2017
    This is my filename|Anne Mustermann|26.11.2017
    This is my filename|Alex Mustermann|27.11.2017

WordPress是如何构建的来保存这些数据的?我如何以正确的方式做到这一点?

感谢您的回答!

行话

试试这个例子,

function bot_install()
{
    global $wpdb;
    $table = $wpdb->prefix."bot_counter";
    $structure = "CREATE TABLE $table (
        id INT(9) NOT NULL AUTO_INCREMENT,
        bot_name VARCHAR(80) NOT NULL,
        bot_mark VARCHAR(20) NOT NULL,
        bot_visits INT(9) DEFAULT 0,
	UNIQUE KEY id (id)
    );";
    $wpdb->query($structure);
 
    // Populate table
    $wpdb->query("INSERT INTO $table(bot_name, bot_mark)
        VALUES('Google Bot', 'googlebot')");
    $wpdb->query("INSERT INTO $table(bot_name, bot_mark)
        VALUES('Yahoo Slurp', 'yahoo')");
}

你得到结果。

最新更新