patch 612202 null for foreign keys
This commit is contained in:
@@ -8,6 +8,8 @@ $Source$
|
|||||||
2002-09-20 Marc Delisle <lem9@users.sourceforge.net>
|
2002-09-20 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* libraries/display_tbl.lib.php3: bug 612117, vertical view and
|
* libraries/display_tbl.lib.php3: bug 612117, vertical view and
|
||||||
buttons as links
|
buttons as links
|
||||||
|
* libraries/tbl_change.js, tbl_change.php3, tbl_replace.php3:
|
||||||
|
patch 612202: NULL for foreign keys, thanks to Markus L. Noga
|
||||||
|
|
||||||
2002-09-19 Marc Delisle <lem9@users.sourceforge.net>
|
2002-09-19 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* libraries/sqlparser.lib.php3: bug 608459: syntax coloring and
|
* libraries/sqlparser.lib.php3: bug 608459: syntax coloring and
|
||||||
|
@@ -18,8 +18,9 @@ function nullify(theType, urlField, md5Field)
|
|||||||
rowForm.elements['funcs[' + urlField + ']'].selectedIndex = -1;
|
rowForm.elements['funcs[' + urlField + ']'].selectedIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "SET" field or "ENUM" field with more than 20 characters
|
// "SET" field , "ENUM" field with more than 20 characters
|
||||||
if (theType == 1 || theType == 3) {
|
// or foreign key field
|
||||||
|
if (theType == 1 || theType == 3 || theType == 4) {
|
||||||
rowForm.elements['field_' + md5Field + '[]'].selectedIndex = -1;
|
rowForm.elements['field_' + md5Field + '[]'].selectedIndex = -1;
|
||||||
}
|
}
|
||||||
// Other "ENUM" field
|
// Other "ENUM" field
|
||||||
@@ -31,7 +32,7 @@ function nullify(theType, urlField, md5Field)
|
|||||||
} // end for
|
} // end for
|
||||||
}
|
}
|
||||||
// Other field types
|
// Other field types
|
||||||
else /*if (theType == 4)*/ {
|
else /*if (theType == 5)*/ {
|
||||||
rowForm.elements['fields[' + urlField + ']'].value = '';
|
rowForm.elements['fields[' + urlField + ']'].value = '';
|
||||||
} // end if... else if... else
|
} // end if... else if... else
|
||||||
|
|
||||||
|
@@ -377,8 +377,10 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
}
|
}
|
||||||
} else if (strstr($row_table_def['True_Type'], 'set')) {
|
} else if (strstr($row_table_def['True_Type'], 'set')) {
|
||||||
$onclick .= '3, ';
|
$onclick .= '3, ';
|
||||||
} else {
|
} else if ($foreigners && isset($foreigners[$field])) {
|
||||||
$onclick .= '4, ';
|
$onclick .= '4, ';
|
||||||
|
} else {
|
||||||
|
$onclick .= '5, ';
|
||||||
}
|
}
|
||||||
$onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
|
$onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
|
||||||
echo $onclick;
|
echo $onclick;
|
||||||
@@ -418,15 +420,21 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
|
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
|
||||||
$dispsql = 'SELECT ' . PMA_backquote($foreign_field)
|
$dispsql = 'SELECT ' . PMA_backquote($foreign_field)
|
||||||
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display))
|
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display))
|
||||||
. ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table);
|
. ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table)
|
||||||
|
. ' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display);
|
||||||
$disp = PMA_mysql_query($dispsql);
|
$disp = PMA_mysql_query($dispsql);
|
||||||
}
|
}
|
||||||
} // end if $foreigners
|
} // end if $foreigners
|
||||||
|
|
||||||
if (isset($disp) && $disp) {
|
if (isset($disp) && $disp) {
|
||||||
echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
|
?>
|
||||||
echo ' ' . $backup_field . "\n";
|
<td bgcolor="<?php echo $bgcolor; ?>">
|
||||||
echo ' <select name="fields[' . urlencode($field) . ']">' . "\n";
|
<?php echo $backup_field . "\n"; ?>
|
||||||
|
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$foreign$" tabindex="<?php echo $i+1; ?>" />
|
||||||
|
<select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo $i+1; ?>">
|
||||||
|
<option value=""></option>
|
||||||
|
<?php
|
||||||
|
|
||||||
while ($relrow = @PMA_mysql_fetch_array($disp)) {
|
while ($relrow = @PMA_mysql_fetch_array($disp)) {
|
||||||
$key = $relrow[$foreign_field];
|
$key = $relrow[$foreign_field];
|
||||||
$value = (($foreign_display != FALSE) ? ' - ' . htmlspecialchars($relrow[$foreign_display]) : '');
|
$value = (($foreign_display != FALSE) ? ' - ' . htmlspecialchars($relrow[$foreign_display]) : '');
|
||||||
|
@@ -118,6 +118,20 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
|
|||||||
$val = "''";
|
$val = "''";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '$foreign$':
|
||||||
|
// if we have a foreign key, then construct the value
|
||||||
|
$f = 'field_' . md5($key);
|
||||||
|
if (!empty($$f)) {
|
||||||
|
$val = implode(',', $$f);
|
||||||
|
if ($val == 'null') {
|
||||||
|
// void
|
||||||
|
} else {
|
||||||
|
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$val = "''";
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (get_magic_quotes_gpc()) {
|
if (get_magic_quotes_gpc()) {
|
||||||
$val = "'" . str_replace('\\"', '"', $val) . "'";
|
$val = "'" . str_replace('\\"', '"', $val) . "'";
|
||||||
|
Reference in New Issue
Block a user