$sql = "DROP TABLE IF EXISTS watchlist"; wfQuery($sql, DB_MASTER); $sql = "CREATE TABLE watchlist (\n wl_user int(5) unsigned NOT NULL,\n wl_page int(8) unsigned NOT NULL,\n UNIQUE KEY (wl_user, wl_page)\n) ENGINE=MyISAM PACK_KEYS=1"; wfQuery($sql, DB_MASTER); $lc = new LinkCache(); # Now, convert! $sql = "SELECT user_id,user_watch FROM user"; $res = wfQuery($sql, DB_SLAVE); $nu = wfNumRows($res); $sql = "INSERT into watchlist (wl_user,wl_page) VALUES "; $i = $n = 0; while ($row = wfFetchObject($res)) { $list = explode("\n", $row->user_watch); $bits = array(); foreach ($list as $title) { if ($id = $lc->addLink($title) and !$bits[$id]++) { $sql .= ($i++ ? "," : "") . "({$row->user_id},{$id})"; } } if ($n++ % 100 == 0) { echo "{$n} of {$nu} users done...\n"; } } echo "{$n} users done.\n"; if ($i) { wfQuery($sql, DB_MASTER); } # Add index # is this necessary? $sql = "ALTER TABLE watchlist\n ADD INDEX wl_user (wl_user),\n ADD INDEX wl_page (wl_page)"; #wfQuery( $sql, DB_MASTER );