• Resolved turkel

    (@turkel)


    Hi,

    I have upgraded my wordpress from 2.8 to 3.0 and now all new new blogs are creates without commentmeta database. I have 3500 blogs and i think on old wp (v2.8) this table also not created and i have just noticed this from error logs.
    Is there are way to create this table for all blogs?
    I am working on script which will create this tables for all blogs but i cant get luck as database is scaled to 16 DBs and while i run script it cant find correct blog_ids on one db. Please, give me some suggestions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter turkel

    (@turkel)

    My script code is this:

    <?php
    error_reporting(E_ALL);
    $db_connect = mysql_connect("localhost","root","");
    if (!$db_connect) {
      die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("wpmu_global", $db_connect);
    $sqlid = "SELECT * FROM wp_blogs";
    $result1 = mysql_query($sqlid) or die(mysql_error());
    
    while($row = mysql_fetch_array($result1)){
    	$blogid = array($row['blog_id']);
    	$data = $row['blog_id'];
    }
    mysql_close($db_connect);
    
    $db_connect = mysql_connect("localhost","root","");
    if (!$db_connect) {
      die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("wpmu_1", $db_connect); //first db and i will run script for each db
    
    foreach ($blogid as &$data) {
    echo $sql = "CREATE TABLE IF NOT EXISTS <code>wp_&quot;.$data.&quot;_commentmetaTest</code> (
      <code>meta_id</code> bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      <code>comment_id</code> bigint(20) unsigned NOT NULL DEFAULT '0',
      <code>meta_key</code> varchar(255) DEFAULT NULL,
      <code>meta_value</code> longtext,
      PRIMARY KEY (<code>meta_id</code>),
      KEY <code>comment_id</code> (<code>comment_id</code>),
      KEY <code>meta_key</code> (<code>meta_key</code>)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
    }
    
    $result = mysql_query($sql) or die(mysql_error());
    
    mysql_close($db_connect);
    ?>

    if the multi db plugin skipped the extra tables, talk to the people you got the plugin from.

    Thread Starter turkel

    (@turkel)

    actually, Multi DB seems works because newly created blogs have required table. Problem is on old ones and that is why i have created this script for to create tables on DBs. This code not works because of Multi DB as i understand.

    Read this:

    https://ocaoimh.ie/wpmu-add-commentmeta/

    And go back to where you got the plugin from and ask them how they handled it with multi dbs.

    Thread Starter turkel

    (@turkel)

    ahh perfect that is what i am trying to create. They have created it as plugin which i have not thought that way lol.

    Thank you very much Andrea_r ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress Multi DB missed table’ is closed to new replies.