/** * @dataProvider dataProvider */ function testConvert_bit_default_value_test($bit, $val) { $this->assertEquals($val, PMA_convertBitDefaultValue($bit)); }
// statement MySQL auto-update it to the current timestamp; // 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) // 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_convertBitDefaultValue($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']) && (isset($_SESSION['tmp_user_values']['display_binary_as_hex']) && $_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; // Get a list of data types that are not yet supported. $no_support_types = PMA_unsupportedDatatypes(); // The function column
echo empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'; ?> </td> <td class="column_attribute nowrap"><?php echo $attribute; ?> </td> <td><?php echo $row['Null'] == 'YES' ? __('Yes') : __('No'); ?> </td> <td class="nowrap"><?php if (isset($row['Default'])) { if ($extracted_columnspec['type'] == 'bit') { // here, $row['Default'] contains something like b'010' echo PMA_convertBitDefaultValue($row['Default']); } else { echo $row['Default']; } } else { echo '<i>' . _pgettext('None for default', 'None') . '</i>'; } ?> </td> <td class="nowrap"><?php echo strtoupper($row['Extra']); ?> </td> <?php if (!$tbl_is_view && !$db_is_information_schema) { ?>
$ci++; // column default // 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_convertBitDefaultValue($row['DefaultValue']); } $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']" class="default_type">'; 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 default_value" />'; $ci++; // column collation
?> </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_convertBitDefaultValue($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']); ?>