Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), $config->getValue( "db_database" ), $config->getValue( "db_character_set" ))) {
die( "could not connect to database!" );
}
$prefix = $config->getValue( "db_prefix" );
$dict = NewPDbDataDictionary( $db );
$errors = false;
$message = "";
foreach( $Tables as $name => $table ) {
$errorMessage = "";
$table_errors = false;
$upperName = $dict->upperName;
$tableSchema = $table["schema"];
if ( isset( $table["options"] ) )
{
$tableOptions = $table["options"];
$options = array ( $upperName => $tableOptions );
} else {
$options = array ();
}
// generate the code with the changes for the table
$sqlarray = $dict->ChangeTableSQL( $prefix.$name, $tableSchema, $options );
foreach( $sqlarray as $sql ) {
// and run the query
if( !$db->Execute( $sql )) {
$table_errors = true;
$errors = true;
$errorMessage .= $db->ErrorMsg()."
";
}
}
if( !$table_errors )
$message .= "Changes to table $name executed successfully.
";
else {
$message .= "Error modifying table $name: ".$errorMessage;
}
}
print($message);
?>