From 23c23a2ce23244971f02cae3051625a14eebde75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Sat, 8 Sep 2001 22:45:58 +0000 Subject: [PATCH] split between NULL value and empty field --- libraries/display_tbl.lib.php3 | 67 +++++++++++++++++----------------- tbl_change.php3 | 12 ++++-- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 1b9f77143..50c7c9b91 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -568,8 +568,11 @@ if (!defined('__LIB_DISPLAY_TBL__')){ // table being displayed has one or more keys; but to display // delete/edit options correctly for tables without keys. - while ($row = mysql_fetch_row($dt_result)) { - $bgcolor = ($foo % 2) ? $GLOBALS['cfgBgcolorOne'] : $GLOBALS['cfgBgcolorTwo']; + // loic1: use 'mysql_fetch_array' rather than 'mysql_fetch_row' to get + // the NULL values + + while ($row = mysql_fetch_array($dt_result)) { + $bgcolor = ($foo % 2) ? $GLOBALS['cfgBgcolorOne'] : $GLOBALS['cfgBgcolorTwo']; ?> @@ -587,11 +590,10 @@ if (!defined('__LIB_DISPLAY_TBL__')){ for ($i = 0; $i < $fields_cnt; ++$i) { $primary = $fields_meta[$i]; $condition = ' ' . backquote($primary->name) . ' '; - if (!isset($row[$i])) { - $row[$i] = ''; + if (!isset($row[$primary->name])) { $condition .= 'IS NULL AND'; } else { - $condition .= '= \'' . sql_addslashes($row[$i]) . '\' AND'; + $condition .= '= \'' . sql_addslashes($row[$primary->name]) . '\' AND'; } if ($primary->primary_key > 0) { $primary_key .= $condition; @@ -610,12 +612,6 @@ if (!defined('__LIB_DISPLAY_TBL__')){ $uva_condition = urlencode(ereg_replace(' ?AND$', '', $uva_condition)); } // end if (1.1) - // 1.2 Results from a "SHOW PROCESSLIST" statement -> gets the - // process id - else if ($is_display['del_lnk'] == 'kp') { - $pma_pid = $row[0]; - } - // 1.2 Defines the urls for the modify/delete link(s) $url_query = 'lang=' . $lang . '&server=' . $server @@ -662,13 +658,13 @@ if (!defined('__LIB_DISPLAY_TBL__')){ . '?lang=' . $lang . '&server=' . $server . '&db=mysql' - . '&sql_query=' . urlencode('KILL ' . $pma_pid) + . '&sql_query=' . urlencode('KILL ' . $row['Id']) . '&goto=main.php3'; - $js_conf = 'KILL ' . $pma_pid; + $js_conf = 'KILL ' . $row['Id']; $del_str = $GLOBALS['strKill']; - } // end if (1.2.1) + } // end if (1.2.2) - // 1.2.3 Displays the links at left if required + // 1.3 Displays the links at left if required if ($GLOBALS['cfgModifyDeleteAtLeft']) { if (!empty($edit_url)) { ?> @@ -688,19 +684,18 @@ if (!defined('__LIB_DISPLAY_TBL__')){ numeric == 1) { - if ($row[$i] != '') { - echo ' ' . $row[$i] . '' . "\n"; + if (!isset($row[$primary->name])) { + echo ' NULL' . "\n"; + } else if ($row[$i] != '') { + echo ' ' . $row[$primary->name] . '' . "\n"; } else { echo '  ' . "\n"; } @@ -713,28 +708,32 @@ if (!defined('__LIB_DISPLAY_TBL__')){ if (eregi('BINARY', $field_flags)) { echo ' [BLOB]' . "\n"; } else { - if (strlen($row[$i]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { - $row[$i] = substr($row[$i], 0, $GLOBALS['cfgLimitChars']) . '...'; - } - // loic1 : displays / - if ($row[$i] != '') { - $row[$i] = ereg_replace("((\015\012)|(\015)|(\012))+", '
', htmlspecialchars($row[$i])); - echo ' ' . $row[$i] . '' . "\n"; + if (!isset($row[$primary->name])) { + echo ' NULL' . "\n"; + } else if ($row[$primary->name] != '') { + if (strlen($row[$primary->name]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { + $row[$primary->name] = substr($row[$primary->name], 0, $GLOBALS['cfgLimitChars']) . '...'; + } + // loic1 : displays / + $row[$primary->name] = ereg_replace("((\015\012)|(\015)|(\012))+", '
', htmlspecialchars($row[$primary->name])); + echo ' ' . $row[$primary->name] . '' . "\n"; } else { echo '  ' . "\n"; } } } else { - // loic1 : displays / - if ($row[$i] != '') { + if (!isset($row[$primary->name])) { + echo ' NULL' . "\n"; + } else if ($row[$primary->name] != '') { // loic1: Cut text/blob fields even if $cfgShowBlob is true if (eregi('BLOB', $primary->type)) { - if (strlen($row[$i]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { - $row[$i] = substr($row[$i], 0, $GLOBALS['cfgLimitChars']) . '...'; + if (strlen($row[$primary->name]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { + $row[$primary->name] = substr($row[$primary->name], 0, $GLOBALS['cfgLimitChars']) . '...'; } } - $row[$i] = ereg_replace("((\015\012)|(\015)|(\012))+", '
', htmlspecialchars($row[$i])); - echo ' ' . $row[$i] . '' . "\n"; + // loic1 : displays / + $row[$primary->name] = ereg_replace("((\015\012)|(\015)|(\012))+", '
', htmlspecialchars($row[$primary->name])); + echo ' ' . $row[$primary->name] . '' . "\n"; } else { echo '  ' . "\n"; } diff --git a/tbl_change.php3 b/tbl_change.php3 index ef6cea8a7..41833c946 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -122,8 +122,14 @@ for ($i = 0; $i < $fields_cnt; $i++) { $special_chars = htmlspecialchars($row[$field]); $data = $row[$field]; $backup_field = ''; + } else if (isset($primary_key)) { + $special_chars = 'NULL'; + $data = ''; + $backup_field = ''; } else { - $data = $special_chars = $backup_field = ''; + $special_chars = ''; + $data = ''; + $backup_field = ''; } // Change by Bernard M. Piller @@ -173,7 +179,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { ?> - + - +