// statement MySQL auto-update it to the current timestamp // lem9: however, things have changed since MySQL 4.1, so // it's better to set a fields_prev in this situation $backup_field = '<input type="hidden" name="fields_prev' . $field_name_appendix . '" value="' . htmlspecialchars($vrow[$field['Field']]) . '" />'; } else { // (we are inserting) // loic1: display default values if (!isset($field['Default'])) { $field['Default'] = ''; $real_null_value = TRUE; $data = ''; } else { $data = $field['Default']; } if ($field['True_Type'] == 'bit') { $special_chars = PMA_convert_bit_default_value($field['Default']); } else { $special_chars = htmlspecialchars($field['Default']); } $backup_field = ''; $special_chars_encoded = PMA_duplicateFirstNewline($special_chars); // this will select the UNHEX function while inserting if (($field['is_binary'] || $field['is_blob'] && !$cfg['ProtectBinary']) && $_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) { $field['display_binary_as_hex'] = true; } } $idindex = $o_rows * $fields_cnt + $i + 1; $tabindex = ($idindex - 1) * 3 + 1; // The function column // ------------------- // Change by Bernard M. Piller <*****@*****.**>
} */ // old column default if ($is_backup) { $_form_params['field_default_orig[' . $i . ']'] = isset($row['Default']) ? $row['Default'] : ''; } // here we put 'NONE' as the default value of drop-down; otherwise // users would have problems if they forget to enter the default // value (example, for an INT) $default_options = array('NONE' => _pgettext('for default', 'None'), 'USER_DEFINED' => __('As defined:'), 'NULL' => 'NULL', 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP'); // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value if ($type_upper == 'TIMESTAMP' && !empty($default_current_timestamp) && isset($row['Default'])) { $row['Default'] = ''; } if ($type_upper == 'BIT') { $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']); } $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">'; foreach ($default_options as $key => $value) { $content_cells[$i][$ci] .= '<option value="' . $key . '"'; // is only set when we go back to edit a field's structure if (isset($row['DefaultType']) && $row['DefaultType'] == $key) { $content_cells[$i][$ci] .= ' selected="selected"'; } $content_cells[$i][$ci] .= ' >' . $value . '</option>'; } $content_cells[$i][$ci] .= '</select>'; $content_cells[$i][$ci] .= '<br />'; $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"' . ' type="text" name="field_default_value[' . $i . ']" size="12"' . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"' . ' class="textfield" />'; $ci++; // column collation
echo empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'; ?> </td> <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?> </td> <td><?php echo $row['Null'] == 'YES' ? $strYes : $strNo; ?> </td> <td nowrap="nowrap"><?php if (isset($row['Default'])) { if ($extracted_fieldspec['type'] == 'bit') { // here, $row['Default'] contains something like b'010' echo PMA_convert_bit_default_value($row['Default']); } else { echo $row['Default']; } } else { echo '<i>' . $strNoneDefault . '</i>'; } ?> </td> <td nowrap="nowrap"><?php echo strtoupper($row['Extra']); ?> </td> <td align="center"> <a href="sql.php?<?php echo $url_query;
/** * display default values * * @param type $column description of column in given table * @param boolean $real_null_value whether column value null or not null * * @return array $real_null_value, $data, $special_chars, * $backup_field, $special_chars_encoded */ function PMA_getSpecialCharsAndBackupFieldForInsertingMode($column, $real_null_value) { if (!isset($column['Default'])) { $column['Default'] = ''; $real_null_value = true; $data = ''; } else { $data = $column['Default']; } if ($column['True_Type'] == 'bit') { $special_chars = PMA_convert_bit_default_value($column['Default']); } else { $special_chars = htmlspecialchars($column['Default']); } $backup_field = ''; $special_chars_encoded = PMA_Util::duplicateFirstNewline($special_chars); // this will select the UNHEX function while inserting if (($column['is_binary'] || $column['is_blob'] && !$GLOBALS['cfg']['ProtectBinary']) && (isset($_SESSION['tmp_user_values']['display_binary_as_hex']) && $_SESSION['tmp_user_values']['display_binary_as_hex']) && $GLOBALS['cfg']['ShowFunctionFields']) { $column['display_binary_as_hex'] = true; } return array($real_null_value, $data, $special_chars, $backup_field, $special_chars_encoded); }
/** * @dataProvider dataProvider */ function testConvert_bit_default_value_test($bit, $val) { $this->assertEquals($val, PMA_convert_bit_default_value($bit)); }
<?php if ($field['Key'] == 'PRI') { echo '<td><b><u>' . htmlspecialchars($field['Field']) . '</u></b></td>' . "\n"; } else { echo '<td><b>' . htmlspecialchars($field['Field']) . '</b></td>' . "\n"; } ?> <td><?php echo htmlspecialchars($field['Type']);?></td> <td><?php echo htmlspecialchars($field['Collation']);?></td> <td><?php echo (($field['Null'] == 'YES') ? __('Yes') : __('No')); ?></td> <td><?php if (isset($field['Default'])) { $extracted_columnspec = PMA_extractColumnSpec($field['Type']); if ($extracted_columnspec['type'] == 'bit') { // here, $field['Default'] contains something like b'010' echo PMA_convert_bit_default_value($field['Default']); } else { echo htmlspecialchars($field['Default']); } } else { if ($field['Null'] == 'YES') { echo '<i>NULL</i>'; } else { echo '<i>' . _pgettext('None for default', 'None') . '</i>'; } } ?></td> <td><?php echo htmlspecialchars($field['Extra']);?></td> <td><?php echo htmlspecialchars($field['Comment']);?></td> </tr> <?php if ($style == 'even') {