dongxue163536
dongxue163536
2017-11-20 11:29

Wordpress - 从自己的插件中保存数据

  • plugins
  • php
  • save
  • wordpress
已采纳

My own wordpress plugin generates this data of a file:

filename|creator|date

    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

How is wordpress built to save this data? How do I do that the right way?

Thanks for your answers!

Lingo

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongyoucha0645 dongyoucha0645 4年前

    Try this example,

    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')");
    }

    You get the result.

    </div>
    
    点赞 评论 复制链接分享

为你推荐