null value checkbox
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2001-12-29 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
|
* tbl_change.php3, tbl_replace.php3, Documentation.html:
|
||||||
|
feature 442855: checkboxes for null values,
|
||||||
|
modifications by Marc and Lo<4C>c
|
||||||
|
|
||||||
2001-12-29 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
2001-12-29 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||||
* header.inc.php3, lines 60-62; libraries/defines.lib.php3, lines 102-103;
|
* header.inc.php3, lines 60-62; libraries/defines.lib.php3, lines 102-103;
|
||||||
libraries/common.lib.php3, lines 672-678: patch #497632 - Support for
|
libraries/common.lib.php3, lines 672-678: patch #497632 - Support for
|
||||||
|
@@ -1209,8 +1209,9 @@
|
|||||||
<p>
|
<p>
|
||||||
<b>How can I insert a null value into my table?</b>
|
<b>How can I insert a null value into my table?</b>
|
||||||
<br />
|
<br />
|
||||||
Enter "null", without the quotes, as the field's value. This is
|
Since version 2.2.3, you have a checkbox for each field that can be null.
|
||||||
especially useful for <tt>Timestamp</tt> or <tt>AutoIncrement</tt> fields.
|
Before 2.2.3, you had to enter "null", without the quotes,
|
||||||
|
as the field's value.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>[phpMyAdmin project]</h3>
|
<h3>[phpMyAdmin project]</h3>
|
||||||
|
@@ -116,7 +116,7 @@ else
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- Change table properties form -->
|
<!-- Change table properties form -->
|
||||||
<form method="post" action="tbl_replace.php3">
|
<form method="post" action="tbl_replace.php3" name="insertForm">
|
||||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||||
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||||
@@ -142,6 +142,7 @@ echo "\n";
|
|||||||
<th><?php echo $strField; ?></th>
|
<th><?php echo $strField; ?></th>
|
||||||
<th><?php echo $strType; ?></th>
|
<th><?php echo $strType; ?></th>
|
||||||
<th><?php echo $strFunction; ?></th>
|
<th><?php echo $strFunction; ?></th>
|
||||||
|
<th><?php echo $strNull; ?></th>
|
||||||
<th><?php echo $strValue; ?></th>
|
<th><?php echo $strValue; ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -202,9 +203,11 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
// loic1: null field value
|
// loic1: null field value
|
||||||
if (!isset($row[$field])) {
|
if (!isset($row[$field])) {
|
||||||
$row[$field] = 'NULL';
|
$row[$field] = 'NULL';
|
||||||
}
|
$special_chars = '';
|
||||||
|
$data = $row[$field];
|
||||||
|
} else {
|
||||||
// loic1: special binary "characters"
|
// loic1: special binary "characters"
|
||||||
else if ($is_binary || $is_blob) {
|
if ($is_binary || $is_blob) {
|
||||||
$row[$field] = str_replace("\x00", '\0', $row[$field]);
|
$row[$field] = str_replace("\x00", '\0', $row[$field]);
|
||||||
$row[$field] = str_replace("\x08", '\b', $row[$field]);
|
$row[$field] = str_replace("\x08", '\b', $row[$field]);
|
||||||
$row[$field] = str_replace("\x0a", '\n', $row[$field]);
|
$row[$field] = str_replace("\x0a", '\n', $row[$field]);
|
||||||
@@ -213,22 +216,26 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
} // end if
|
} // end if
|
||||||
$special_chars = htmlspecialchars($row[$field]);
|
$special_chars = htmlspecialchars($row[$field]);
|
||||||
$data = $row[$field];
|
$data = $row[$field];
|
||||||
|
} // end if... else...
|
||||||
// loic1: if a timestamp field value is not included in an update
|
// loic1: if a timestamp field value is not included in an update
|
||||||
// statement MySQL auto-update it to the current timestamp
|
// statement MySQL auto-update it to the current timestamp
|
||||||
$backup_field = ($row_table_def['True_Type'] == 'timestamp')
|
$backup_field = ($row_table_def['True_Type'] == 'timestamp')
|
||||||
? ''
|
? ''
|
||||||
: '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($data) . '" />';
|
: '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($row[$field]) . '" />';
|
||||||
} else {
|
} else {
|
||||||
// loic1: display default values
|
// loic1: display default values
|
||||||
if (!isset($row_table_def['Default'])) {
|
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']);
|
$special_chars = htmlspecialchars($row_table_def['Default']);
|
||||||
$data = $row_table_def['Default'];
|
|
||||||
$backup_field = '';
|
$backup_field = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// The function column
|
// The function column
|
||||||
|
// -------------------
|
||||||
// Change by Bernard M. Piller <bernard@bmpsystems.com>
|
// Change by Bernard M. Piller <bernard@bmpsystems.com>
|
||||||
// We don't want binary data to be destroyed
|
// We don't want binary data to be destroyed
|
||||||
// Note: from the MySQL manual: "BINARY doesn't affect how the column is
|
// 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";
|
echo "\n";
|
||||||
|
|
||||||
|
// The null column
|
||||||
|
// ---------------
|
||||||
|
echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
|
||||||
|
if ($row_table_def['Null'] == 'YES') {
|
||||||
|
echo ' <input type="checkbox"'
|
||||||
|
. ' name="fields_null[' . urlencode($field) . ']"';
|
||||||
|
if ($data == 'NULL') {
|
||||||
|
echo ' checked="checked"';
|
||||||
|
}
|
||||||
|
echo ' onclick="if (this.checked) {document.forms[\'insertForm\'].elements[\'fields[' . urlencode($field) . ']\'].value = \'\'}; return true" />' . "\n";
|
||||||
|
} else {
|
||||||
|
echo ' ' . "\n";
|
||||||
|
}
|
||||||
|
echo ' </td>' . "\n";
|
||||||
|
|
||||||
// The value column (depends on type)
|
// The value column (depends on type)
|
||||||
|
// ----------------
|
||||||
if (strstr($row_table_def['True_Type'], 'text')) {
|
if (strstr($row_table_def['True_Type'], 'text')) {
|
||||||
?>
|
?>
|
||||||
<td bgcolor="<?php echo $bgcolor; ?>">
|
<td bgcolor="<?php echo $bgcolor; ?>">
|
||||||
@@ -289,7 +312,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
$enum = ereg_replace('\\)$', '', $enum);
|
$enum = ereg_replace('\\)$', '', $enum);
|
||||||
$enum = explode('\',\'', substr($enum, 1, -1));
|
$enum = explode('\',\'', substr($enum, 1, -1));
|
||||||
$enum_cnt = count($enum);
|
$enum_cnt = count($enum);
|
||||||
$seenchecked = 0;
|
// $seenchecked = 0;
|
||||||
?>
|
?>
|
||||||
<td bgcolor="<?php echo $bgcolor; ?>">
|
<td bgcolor="<?php echo $bgcolor; ?>">
|
||||||
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$enum$" />
|
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$enum$" />
|
||||||
@@ -313,23 +336,21 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
if ($data == $enum_atom
|
if ($data == $enum_atom
|
||||||
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
|
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
|
||||||
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
|
&& 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"';
|
echo ' selected="selected"';
|
||||||
$seenchecked = 1;
|
// $seenchecked = 1;
|
||||||
}
|
}
|
||||||
echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
|
echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if ($row_table_def['Null'] == 'YES') {
|
// old null option
|
||||||
echo ' ';
|
// if ($row_table_def['Null'] == 'YES') {
|
||||||
echo '<option value="null"';
|
// echo ' ';
|
||||||
if ($seenchecked == 0) {
|
// echo '<option value="null"';
|
||||||
echo ' selected="selected"';
|
// if ($seenchecked == 0) {
|
||||||
}
|
// echo ' selected="selected"';
|
||||||
echo '>[' . $strNull . ']</option>' . "\n";
|
// }
|
||||||
} // end if
|
// echo '>[' . $strNull . ']</option>' . "\n";
|
||||||
|
// } // end if
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<?php
|
<?php
|
||||||
@@ -344,25 +365,23 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
if ($data == $enum_atom
|
if ($data == $enum_atom
|
||||||
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
|
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
|
||||||
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
|
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
|
||||||
// To be able to display a checkmark in the [Null] box when
|
|
||||||
// the field is null, we lose the ability to display a
|
|
||||||
// checkmark besides the default value
|
|
||||||
echo ' checked="checked"';
|
echo ' checked="checked"';
|
||||||
$seenchecked = 1;
|
// $seenchecked = 1;
|
||||||
}
|
}
|
||||||
echo ' />' . "\n";
|
echo ' />' . "\n";
|
||||||
echo ' ' . htmlspecialchars($enum_atom) . "\n";
|
echo ' ' . htmlspecialchars($enum_atom) . "\n";
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if ($row_table_def['Null'] == 'YES') {
|
// old null option
|
||||||
echo ' ';
|
// if ($row_table_def['Null'] == 'YES') {
|
||||||
echo '<input type="radio" name="field_' . md5($field) . '[]" value="null"';
|
// echo ' ';
|
||||||
if ($seenchecked == 0) {
|
// echo '<input type="radio" name="field_' . md5($field) . '[]" value="null"';
|
||||||
echo ' checked="checked"';
|
// if ($seenchecked == 0) {
|
||||||
}
|
// echo ' checked="checked"';
|
||||||
echo ' />' . "\n";
|
// }
|
||||||
echo ' [' . $strNull . ']' . "\n";
|
// echo ' />' . "\n";
|
||||||
} // end if
|
// echo ' [' . $strNull . ']' . "\n";
|
||||||
|
// } // end if
|
||||||
} // end else
|
} // end else
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
|
@@ -105,6 +105,11 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
|
|||||||
break;
|
break;
|
||||||
} // end switch
|
} // 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
|
// No change for this column and no MySQL function is used -> next column
|
||||||
if (empty($funcs[$encoded_key])
|
if (empty($funcs[$encoded_key])
|
||||||
&& isset($fields_prev) && isset($fields_prev[$encoded_key])
|
&& isset($fields_prev) && isset($fields_prev[$encoded_key])
|
||||||
@@ -192,6 +197,11 @@ else {
|
|||||||
break;
|
break;
|
||||||
} // end switch
|
} // 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])) {
|
if (empty($funcs[$encoded_key])) {
|
||||||
$valuelist .= $val . ', ';
|
$valuelist .= $val . ', ';
|
||||||
} else if ($val == '\'\''
|
} else if ($val == '\'\''
|
||||||
|
Reference in New Issue
Block a user