diff --git a/ChangeLog b/ChangeLog index 83ccfea3f..fbb0eaab8 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ $Source$ 2003-04-17 Garvin Hicking * tbl_replace_fields.php3: Use $encoded_key instead of $key to detect changes in BLOB fields with a special name. + * tbl_replace.php3, tbl_replace_fields.php3: Bug #722629 - Use + original values of a BLOB field when 'Insert as new row' is + chosen on edit. 2003-04-16 Garvin Hicking * tbl_query_box.php3: Only hide 'go' SQL button, when in files mode diff --git a/tbl_replace.php3 b/tbl_replace.php3 index 94a84ac56..bd7b92bb9 100755 --- a/tbl_replace.php3 +++ b/tbl_replace.php3 @@ -105,6 +105,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { // Builds the sql update query $valuelist = ereg_replace(', $', '', $valuelist); if (!empty($valuelist)) { + PMA_mysql_select_db($db); $query = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key . ((PMA_MYSQL_INT_VERSION >= 32300) ? ' LIMIT 1' : ''); $message = $strAffectedRows . ' '; @@ -128,8 +129,28 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { * Prepares the insert of a row */ else { + PMA_mysql_select_db($db); + $fieldlist = ''; $valuelist = ''; + + // garvin: Get, if sent, any protected fields to insert them here: + if (isset($fields_type) && is_array($fields_type) && isset($primary_key)) { + reset($fields_type); + + $protected_stack = array(); + while (list($key, $val) = each($fields_type)) { + if ($val == 'protected') { + $protected_stack[] = PMA_backquote(urldecode($key)); + } + } + reset($fields_type); + + $prot_local_query = 'SELECT ' . implode(', ', $protected_stack) . ' FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($primary_key); + $prot_result = PMA_mysql_query($prot_local_query) or PMA_mysqlDie('', $prot_local_query, '', $err_url); + $prot_row = PMA_mysql_fetch_array($prot_result); + } + while (list($key, $val) = each($fields)) { $encoded_key = $key; $key = urldecode($key); @@ -160,7 +181,6 @@ else { * Executes the sql query and get the result, then move back to the calling * page */ -PMA_mysql_select_db($db); $sql_query = $query . ';'; $result = PMA_mysql_query($query); if (!$result) { diff --git a/tbl_replace_fields.php3 b/tbl_replace_fields.php3 index 3855b85e0..485c0911e 100755 --- a/tbl_replace_fields.php3 +++ b/tbl_replace_fields.php3 @@ -160,9 +160,15 @@ if (!$check_stop) { // but we can still handle field upload // garvin: when in UPDATE mode, do not alter field's contents. When in INSERT - // mode, insert empty field because no values were submitted. + // mode, insert empty field because no values were submitted. If protected + // blobs where set, insert original fields content. if (isset($fieldlist)) { - $val = "''"; + if (isset($prot_row) && isset($prot_row[$key]) && $prot_row[$key] != '') { + $val = '0x' . bin2hex($prot_row[$key]); + $see_binary = true; + } else { + $val = "''"; + } } else { unset($val); }