This commit is contained in:
Garvin Hicking
2003-04-17 15:02:49 +00:00
parent 9dff46d0ac
commit 94fc3097ac
3 changed files with 32 additions and 3 deletions

View File

@@ -8,6 +8,9 @@ $Source$
2003-04-17 Garvin Hicking <me@supergarv.de>
* 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 <me@supergarv.de>
* tbl_query_box.php3: Only hide 'go' SQL button, when in files mode

View File

@@ -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 . '&nbsp;';
@@ -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) {

View File

@@ -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)) {
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);
}