diff --git a/tbl_change.php b/tbl_change.php index 05085439d..7a8faa37e 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -310,11 +310,6 @@ foreach ($rows as $row_id => $vrow) {
$vrow) { $table_fields[$i]['Field_html'] = htmlspecialchars($table_fields[$i]['Field']); $table_fields[$i]['Field_md5'] = md5($table_fields[$i]['Field']); $table_fields[$i]['True_Type'] = preg_replace('@\(.*@s', '', $table_fields[$i]['Type']); + + // d a t e t i m e + // + // loic1: current date should not be set as default if the field is NULL + // for the current row + // lem9: but do not put here the current datetime if there is a default + // value (the real default value will be set in the + // Default value logic below) + + // Note: (tested in MySQL 4.0.16): when lang is some UTF-8, + // $field['Default'] is not set if it contains NULL: + // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime) + // but, look what we get if we switch to iso: (Default is NULL) + // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime) + // so I force a NULL into it (I don't think it's possible + // to have an empty default value for DATETIME) + // then, the "if" after this one will work + if ($table_fields[$i]['Type'] == 'datetime' + && ! isset($table_fields[$i]['Default']) + && isset($table_fields[$i]['Null']) + && $table_fields[$i]['Null'] == 'YES') { + $table_fields[$i]['Default'] = null; + } + + $table_fields[$i]['len'] = + preg_match('@float|double@', $table_fields[$i]['Type']) ? 100 : -1; + + + if (isset($comments_map[$table_fields[$i]['Field']])) { + $table_fields[$i]['Field_title'] = '' + . $table_fields[$i]['Field_html'] . ''; + } else { + $table_fields[$i]['Field_title'] = $table_fields[$i]['Field_html']; + } + + // The type column + $table_fields[$i]['is_binary'] = stristr($table_fields[$i]['Type'], 'binary'); + $table_fields[$i]['is_blob'] = stristr($table_fields[$i]['Type'], 'blob'); + $table_fields[$i]['is_char'] = stristr($table_fields[$i]['Type'], 'char'); + $table_fields[$i]['first_timestamp'] = false; + switch ($table_fields[$i]['True_Type']) { + case 'set': + $table_fields[$i]['pma_type'] = 'set'; + $table_fields[$i]['wrap'] = ''; + break; + case 'enum': + $table_fields[$i]['pma_type'] = 'enum'; + $table_fields[$i]['wrap'] = ''; + break; + case 'timestamp': + if (!$timestamp_seen) { // can only occur once per table + $timestamp_seen = 1; + $table_fields[$i]['first_timestamp'] = true; + } + $table_fields[$i]['pma_type'] = $table_fields[$i]['Type']; + $table_fields[$i]['wrap'] = ' nowrap="nowrap"'; + break; + + default: + $table_fields[$i]['pma_type'] = $table_fields[$i]['Type']; + $table_fields[$i]['wrap'] = ' nowrap="nowrap"'; + break; + } } $field = $table_fields[$i]; + if (-1 === $field['len']) { + $field['len'] = PMA_DBI_field_len($vresult, $i); + } + $unnullify_trigger = $chg_evt_handler . "=\"return unNullify('" . PMA_escapeJsString($field['Field_html']) . "', '" . PMA_escapeJsString($jsvkey) . "')\""; @@ -334,33 +397,6 @@ foreach ($rows as $row_id => $vrow) { $field_name_appendix_md5 = $field['Field_md5'] . $vkey . '[]'; - // removed previous PHP3-workaround that caused a problem with - // field names like '000' - //$rowfield = $field; - - // d a t e t i m e - // - // loic1: current date should not be set as default if the field is NULL - // for the current row - // lem9: but do not put here the current datetime if there is a default - // value (the real default value will be set in the - // Default value logic below) - - // Note: (tested in MySQL 4.0.16): when lang is some UTF-8, - // $field['Default'] is not set if it contains NULL: - // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime) - // but, look what we get if we switch to iso: (Default is NULL) - // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime) - // so I force a NULL into it (I don't think it's possible - // to have an empty default value for DATETIME) - // then, the "if" after this one will work - if ($field['Type'] == 'datetime' - && ! isset($field['Default']) - && isset($field['Null']) - && $field['Null'] == 'YES') { - $field['Default'] = null; - } - if ($field['Type'] == 'datetime' && ! isset($field['Default']) && ! is_null($field['Default'])) { @@ -373,52 +409,11 @@ foreach ($rows as $row_id => $vrow) { $vrow[$field['Field']] = date('Y-m-d H:i:s', time()); } // end if... elseif... } - $len = (preg_match('@float|double@', $field['Type'])) - ? 100 - : PMA_DBI_field_len($vresult, $i); - $first_timestamp = 0; - - $field_name = $field['Field_html']; - if (isset($comments_map[$field['Field']])) { - $field_name = '' . $field_name . ''; - } - ?>