From 33c1195875b34562f28b3b76c201d9042b1db610 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 30 Dec 2001 01:19:45 +0000 Subject: [PATCH] null value checkbox --- ChangeLog | 5 +++ Documentation.html | 5 ++- tbl_change.php3 | 103 +++++++++++++++++++++++++++------------------ tbl_replace.php3 | 12 +++++- 4 files changed, 80 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index d287822ca..d4e1bf6bc 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2001-12-29 Marc Delisle + * tbl_change.php3, tbl_replace.php3, Documentation.html: + feature 442855: checkboxes for null values, + modifications by Marc and Loïc + 2001-12-29 Loïc Chapeaux * header.inc.php3, lines 60-62; libraries/defines.lib.php3, lines 102-103; libraries/common.lib.php3, lines 672-678: patch #497632 - Support for diff --git a/Documentation.html b/Documentation.html index 1397907b3..b2ea0e906 100755 --- a/Documentation.html +++ b/Documentation.html @@ -1209,8 +1209,9 @@

How can I insert a null value into my table?
- Enter "null", without the quotes, as the field's value. This is - especially useful for Timestamp or AutoIncrement fields. + Since version 2.2.3, you have a checkbox for each field that can be null. + Before 2.2.3, you had to enter "null", without the quotes, + as the field's value.

[phpMyAdmin project]

diff --git a/tbl_change.php3 b/tbl_change.php3 index d253d111a..1f04ba417 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -116,7 +116,7 @@ else ?> -
+ @@ -142,6 +142,7 @@ echo "\n"; + @@ -201,34 +202,40 @@ for ($i = 0; $i < $fields_cnt; $i++) { if (isset($row)) { // loic1: null field value if (!isset($row[$field])) { - $row[$field] = 'NULL'; - } - // loic1: special binary "characters" - else if ($is_binary || $is_blob) { - $row[$field] = str_replace("\x00", '\0', $row[$field]); - $row[$field] = str_replace("\x08", '\b', $row[$field]); - $row[$field] = str_replace("\x0a", '\n', $row[$field]); - $row[$field] = str_replace("\x0d", '\r', $row[$field]); - $row[$field] = str_replace("\x1a", '\Z', $row[$field]); - } // end if - $special_chars = htmlspecialchars($row[$field]); - $data = $row[$field]; + $row[$field] = 'NULL'; + $special_chars = ''; + $data = $row[$field]; + } else { + // loic1: special binary "characters" + if ($is_binary || $is_blob) { + $row[$field] = str_replace("\x00", '\0', $row[$field]); + $row[$field] = str_replace("\x08", '\b', $row[$field]); + $row[$field] = str_replace("\x0a", '\n', $row[$field]); + $row[$field] = str_replace("\x0d", '\r', $row[$field]); + $row[$field] = str_replace("\x1a", '\Z', $row[$field]); + } // end if + $special_chars = htmlspecialchars($row[$field]); + $data = $row[$field]; + } // end if... else... // loic1: if a timestamp field value is not included in an update // statement MySQL auto-update it to the current timestamp $backup_field = ($row_table_def['True_Type'] == 'timestamp') ? '' - : ''; + : ''; } else { // loic1: display default values if (!isset($row_table_def['Default'])) { - $row_table_def['Default'] = (($row_table_def['Null'] == 'YES') ? 'NULL' : ''); + $row_table_def['Default'] = ''; + $data = 'NULL'; + } else { + $data = $row_table_def['Default']; } $special_chars = htmlspecialchars($row_table_def['Default']); - $data = $row_table_def['Default']; $backup_field = ''; } // The function column + // ------------------- // Change by Bernard M. Piller // We don't want binary data to be destroyed // Note: from the MySQL manual: "BINARY doesn't affect how the column is @@ -271,7 +278,23 @@ for ($i = 0; $i < $fields_cnt; $i++) { } echo "\n"; + // The null column + // --------------- + echo ' ' . "\n"; + if ($row_table_def['Null'] == 'YES') { + echo ' ' . "\n"; + } else { + echo '  ' . "\n"; + } + echo ' ' . "\n"; + // The value column (depends on type) + // ---------------- if (strstr($row_table_def['True_Type'], 'text')) { ?> @@ -289,7 +312,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { $enum = ereg_replace('\\)$', '', $enum); $enum = explode('\',\'', substr($enum, 1, -1)); $enum_cnt = count($enum); - $seenchecked = 0; +// $seenchecked = 0; ?> @@ -313,23 +336,21 @@ for ($i = 0; $i < $fields_cnt; $i++) { if ($data == $enum_atom || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES') && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) { - // To be able to select the [Null] value when the field is - // null, we lose the ability to select besides the default - // value echo ' selected="selected"'; - $seenchecked = 1; +// $seenchecked = 1; } echo '>' . htmlspecialchars($enum_atom) . '' . "\n"; } // end for - if ($row_table_def['Null'] == 'YES') { - echo ' '; - echo '' . "\n"; - } // end if +// old null option +// if ($row_table_def['Null'] == 'YES') { +// echo ' '; +// echo '' . "\n"; +// } // end if ?> ' . "\n"; echo ' ' . htmlspecialchars($enum_atom) . "\n"; } // end for - if ($row_table_def['Null'] == 'YES') { - echo ' '; - echo '' . "\n"; - echo ' [' . $strNull . ']' . "\n"; - } // end if +// old null option +// if ($row_table_def['Null'] == 'YES') { +// echo ' '; +// echo '' . "\n"; +// echo ' [' . $strNull . ']' . "\n"; +// } // end if } // end else echo "\n"; ?> diff --git a/tbl_replace.php3 b/tbl_replace.php3 index 72ebe96de..d9e067a0a 100755 --- a/tbl_replace.php3 +++ b/tbl_replace.php3 @@ -105,6 +105,11 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { break; } // end switch + // Was the Null checkbox checked for this field? + if (isset($fields_null) && isset($fields_null[$encoded_key])) { + $val = 'NULL'; + } + // No change for this column and no MySQL function is used -> next column if (empty($funcs[$encoded_key]) && isset($fields_prev) && isset($fields_prev[$encoded_key]) @@ -154,7 +159,7 @@ else { while (list($key, $val) = each($fields)) { $encoded_key = $key; $key = urldecode($key); - $fieldlist .= PMA_backquote($key) . ', '; + $fieldlist .= PMA_backquote($key) . ', '; switch (strtolower($val)) { case 'null': @@ -192,6 +197,11 @@ else { break; } // end switch + // Was the Null checkbox checked for this field? + if (isset($fields_null) && isset($fields_null[$encoded_key])) { + $val = 'NULL'; + } + if (empty($funcs[$encoded_key])) { $valuelist .= $val . ', '; } else if ($val == '\'\''