Database Creation Suppressed, SQL Queries follow ';
}
# Make sure we do the upgrades using UTF-8 if needed
if ( $f_db_type === 'mysql' || $f_db_type === 'mysqli' ) {
$g_db->execute( 'SET NAMES UTF8' );
}
if( $f_db_type == 'db2' ) {
$result = &$g_db->execute( 'set schema ' . $f_db_schema );
if( $result === false ) {
echo $g_db->errorMsg();
}
}
while(( $i <= $lastid ) && !$g_failed ) {
if( !$f_log_queries ) {
echo '';
}
$dict = NewDataDictionary( $g_db );
$t_sql = true;
$t_target = $upgrade[$i][1][0];
if( $upgrade[$i][0] == 'InsertData' ) {
$sqlarray = call_user_func_array( $upgrade[$i][0], $upgrade[$i][1] );
}
else if( $upgrade[$i][0] == 'UpdateSQL' ) {
$sqlarray = array(
$upgrade[$i][1],
);
$t_target = $upgrade[$i][1];
} else if( $upgrade[$i][0] == 'UpdateFunction' ) {
$sqlarray = array(
$upgrade[$i][1],
);
if( isset( $upgrade[$i][2] ) ) {
$sqlarray[] = $upgrade[$i][2];
}
$t_sql = false;
$t_target = $upgrade[$i][1];
} else {
/* 0: function to call, 1: function params, 2: function to evaluate before calling upgrade, if false, skip upgrade. */
if( isset( $upgrade[$i][2] ) ) {
if( call_user_func_array( $upgrade[$i][2][0], $upgrade[$i][2][1] ) ) {
$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
} else {
$sqlarray = array();
}
} else {
$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
}
}
if( $f_log_queries ) {
if( $t_sql ) {
foreach( $sqlarray as $sql ) {
echo htmlentities( $sql ) . ";\r\n\r\n";
}
}
} else {
echo 'Schema ' . $upgrade[$i][0] . ' ( ' . $t_target . ' ) | ';
if( $t_sql ) {
$ret = $dict->ExecuteSQLArray( $sqlarray, false );
} else {
if( isset( $sqlarray[1] ) ) {
$ret = call_user_func( 'install_' . $sqlarray[0], $sqlarray[1] );
} else {
$ret = call_user_func( 'install_' . $sqlarray[0] );
}
}
if( $ret == 2 ) {
print_test_result( GOOD );
config_set( 'database_version', $i );
} else {
$all_sql = '';
foreach ( $sqlarray as $single_sql )
$all_sql .= $single_sql . ' ';
print_test_result( BAD, true, $all_sql . $g_db->ErrorMsg() );
}
echo ' ';
}
$i++;
}
if( $f_log_queries ) {
# add a query to set the database version
echo 'INSERT INTO ' . db_get_table( 'mantis_config_table' ) . ' ( value, type, access_reqd, config_id, project_id, user_id ) VALUES (\'' . $lastid . '\', 1, 90, \'database_version\', 0, 0 );' . "\r\n";
echo ' Your database has not been created yet. Please create the database, then install the tables and data using the information above before proceeding. |
';
}
}
if( false == $g_failed ) {
$t_install_state++;
} else {
$t_install_state--;
}
?>