} $res = mysql_query("INSERT INTO `{$config['table_name_v3']}`(token, count_ham) VALUES('b8*dbversion', '3')", $db_v3); if ($res !== TRUE) { update_failed('failed', "Could not insert data ('b8*dbversion', '3') into table \"{$config['table_name_v3']}\": " . mysql_error()); } echo "done<br />\n"; echo "Processing all tokens … "; $processed = 0; $res = mysql_query("SELECT token, count FROM `{$config['table_name_v2']}` WHERE token != 'bayes*dbversion' AND token != 'bayes*texts.ham' AND token != 'bayes*texts.spam'", $db_v2); while ($dat = mysql_fetch_assoc($res)) { $token = mysql_real_escape_string($dat['token'], $db_v3); $parts = explode(' ', $dat['count']); $ham = $parts[0]; $spam = $parts[1]; $res2 = mysql_query("INSERT INTO `{$config['table_name_v3']}`(token, count_ham, count_spam) VALUES('{$token}', '{$ham}', '{$spam}')", $db_v3); if ($res2 !== TRUE) { update_failed('failed', "Could not insert data ('{$token}', '{$ham}', '{$spam}') into table \"{$config['table_name_v3']}\": " . mysql_error()); } else { $processed++; } } echo "processed {$processed} tokens\n</p>\n\n"; echo "<p>Finished database update to version 3. The new database table is \"{$config['table_name_v3']}\".</p>\n"; ?> </div> </body> </html>
} if ($key == 'bayes*texts.spam') { $internals_texts_spam = $val; } } else { $parts = explode(' ', $val); $val_processed = "{$parts[0]} {$parts[1]}"; # Store it to the new database if (dba_insert($key, $val_processed, $db_v3) !== TRUE) { update_failed('failed', "Failed to insert token \"{$key}\""); } $processed++; } $key = dba_nextkey($db_v2); } # Re-insert the internal variables foreach (array('b8*dbversion' => '3', 'b8*texts' => "{$internals_texts_ham} {$internals_texts_spam}") as $key => $val) { if (dba_insert($key, $val, $db_v3) !== TRUE) { update_failed('failed', "Failed to insert token \"{$key}\""); } } echo "processed {$processed} tokens\n</p>\n\n"; echo "<p>Finished database update to version 3. The new database file is \"{$dbfile_v3_html}\".</p>\n"; ?> </div> </body> </html>