• Resolved allstar

    (@allstar)


    On activation I’m trying to have WP create 2 tables that my ‘plugin’ will need. I’ve tried using deltadb() and wpdb->query.

    The SQL is properly formed (literally just a cut and paste out of a MySQL 4.0 export).

    I either get 1 table created or none respectively. Where am I going wrong?


    require_once(ABSPATH . "wp-admin/upgrade-functions.php");
    // if database table doesn't already exist
    if ($installed_ver === false || $installed_ver != $plugin_db_version) {

    $sql_one = "CREATE TABLE " . $this->db_table_one . " (
    <FIELDS>
    ) TYPE=InnoDB;";
    dbDelta($sql_one);

    $sql_two = "CREATE TABLE " . $this->db_table_two . " (
    <FIELDS>
    ) TYPE=InnoDB;";
    dbDelta($sql_two);
    }

Viewing 1 replies (of 1 total)
  • Thread Starter allstar

    (@allstar)

    The initial test was creating 1 Database table. Which stored the database version number.

    The reason the plugin didn’t create the 3 tables was it was checking to see if the current database was a modern version. Which it was so it didn’t need to add the ‘new’ tables.

    Deleting the database version number from wp_options allowed all 3 tables to be created on installation.

Viewing 1 replies (of 1 total)
  • The topic ‘Multiple Database Tables for Plugin’ is closed to new replies.