00001 <?php
00002
00008 if (!defined( "PLOG_CLASS_PATH" )) {
00009 define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
00010 }
00011
00012 lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
00013 lt_include( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" );
00014 lt_include( PLOG_CLASS_PATH."install/dbschemas.properties.php" );
00015
00016 $config = new ConfigFileStorage();
00017
00018 $db = PDb::getDriver('mysql');
00019
00020 if( !$db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), $config->getValue( "db_database" ), $config->getValue( "db_character_set" ))) {
00021 die( "could not connect to database!" );
00022 }
00023
00024 $prefix = $config->getValue( "db_prefix" );
00025
00026 $dict = NewPDbDataDictionary( $db );
00027 $errors = false;
00028 $message = "";
00029 foreach( $Tables as $name => $table ) {
00030 $errorMessage = "";
00031 $table_errors = false;
00032 $upperName = $dict->upperName;
00033 $tableSchema = $table["schema"];
00034 if ( isset( $table["options"] ) )
00035 {
00036 $tableOptions = $table["options"];
00037 $options = array ( $upperName => $tableOptions );
00038 } else {
00039 $options = array ();
00040 }
00041
00042
00043 $sqlarray = $dict->ChangeTableSQL( $prefix.$name, $tableSchema, $options );
00044
00045 foreach( $sqlarray as $sql ) {
00046
00047 if( !$db->Execute( $sql )) {
00048 $table_errors = true;
00049 $errors = true;
00050 $errorMessage .= $db->ErrorMsg()."<br/>";
00051 }
00052 }
00053
00054 if( !$table_errors )
00055 $message .= "Changes to table <strong>$name</strong> executed successfully.<br/>";
00056 else {
00057 $message .= "Error modifying table $name: ".$errorMessage;
00058 }
00059 }
00060
00061 print($message);
00062
00063 ?>