• Hi, I’m unable to get the tables from my plugin created at network activate.
    I can see the progress bar counting up for all blogs but no tables are created. Is there something wrong with my plugin?

    function _assert_db_structure() {
    			global $wpdb;
    
    			$wpdb->query("CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."blogstats ( <code>stat_post_id</code> int NOT NULL default '0', <code>stat_date</code> datetime NOT NULL default '0000-00-00 00:00:00' , <code>stat_visitor_id</code> VARCHAR( 32 ) NULL , INDEX ".$wpdb->prefix."blogstats_post_ids (stat_post_id,stat_date)) ENGINE = MYISAM");
    
    			 $wpdb->query("CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."blogstats_daily (<code>stat_post_id</code> INT NOT NULL DEFAULT '0', <code>day</code> DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', <code>unique_visits</code> INT NOT NULL DEFAULT '0', <code>total_visits</code> INT NOT NULL DEFAULT '0', INDEX ".$wpdb->prefix."blogstats_daily_post_ids (stat_post_id,day) ) ENGINE = MYISAM");
    
    			$wpdb->query("CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."blogstats_total (<code>stat_post_id</code> INT NOT NULL DEFAULT '0', <code>until_day</code> DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', <code>unique_visits</code> INT NOT NULL DEFAULT '0', <code>total_visits</code> INT NOT NULL DEFAULT '0') ENGINE = MYISAM");
    
    			// If indexes dont exist after update
    			$result = $wpdb->get_results("show index from ".$wpdb->prefix."blogstats where key_name='".$wpdb->prefix."blogstats_post_ids'", ARRAY_N);
    			if (count($result) == 0) {
    				$wpdb->query("CREATE INDEX ".$wpdb->prefix."blogstats_post_ids on ".$wpdb->prefix."blogstats (stat_post_id,stat_date);");
    			}
    
    			$result = $wpdb->get_results("show index from ".$wpdb->prefix."blogstats_daily where key_name='".$wpdb->prefix."blogstats_daily_post_ids'", ARRAY_N);
    			if (count($result) == 0) {
    				$wpdb->query("CREATE INDEX ".$wpdb->prefix."blogstats_daily_post_ids on ".$wpdb->prefix."blogstats_daily (stat_post_id,day);");
    			}
    
    		}

    Many thanks
    Tomas

    http://wordpress.org/extend/plugins/proper-network-activation/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author scribu

    (@scribu)

    You pasted the code for the _assert_db_structure() function, but where are you hooking it?

    Thread Starter Tomas

    (@spotlife)

    Thanks for your prompt reply.
    hmm I’m no good with plugins so I’m not sure what you mean. Can I post the complete plugin so you can have a look?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cannot create tables on net activate even with proper network activate installed’ is closed to new replies.