Remove unnecessary codes for Inline Edit functionality
This commit is contained in:
parent
b11c420096
commit
c2fcb53fa6
@ -1213,31 +1213,6 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
|
||||
if (data.success == true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
|
||||
// Generate new where clause again if the column
|
||||
// can be truncated by MySQL and table does not have
|
||||
// primary/unique key
|
||||
if (data.isNeedToRecheck && !data.hasUniqueIdentifier) {
|
||||
|
||||
var $toBeSavedColumn = $('.to_be_saved');
|
||||
var condition_array = jQuery.parseJSON($toBeSavedColumn.parent().find('.condition_array').val());
|
||||
var field_name = getFieldName($toBeSavedColumn);
|
||||
var field_str = '`' + g.table + '`.' + '`' + field_name + '`';
|
||||
condition_array[field_str] = ' =' + data.truncatableFieldValue;
|
||||
|
||||
// save new_clause
|
||||
var new_clause = '';
|
||||
for (var field in condition_array) {
|
||||
new_clause += field + ' ' + condition_array[field] + ' AND ';
|
||||
}
|
||||
new_clause = new_clause.substring(0, new_clause.length - 5); // remove the last AND
|
||||
new_clause = PMA_urlencode(new_clause);
|
||||
$toBeSavedColumn.parent().data('new_clause', new_clause);
|
||||
|
||||
// save condition_array
|
||||
$toBeSavedColumn.parent().find('.condition_array').val(JSON.stringify(condition_array));
|
||||
|
||||
}
|
||||
|
||||
// update where_clause related data in each edited row
|
||||
$('td.to_be_saved').parents('tr').each(function() {
|
||||
var new_clause = $(this).data('new_clause');
|
||||
|
||||
@ -2331,27 +2331,6 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether particular table has primary key or unique key
|
||||
*
|
||||
* @param string $db Database name
|
||||
* @param string $table Table name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function PMA_hasPrimaryKeyOrUniqueKey($db, $table)
|
||||
{
|
||||
$table_indexes = PMA_DBI_get_table_indexes($db, $table);
|
||||
|
||||
foreach ($table_indexes as $index) {
|
||||
if (($index['Key_name'] == 'PRIMARY') || ($index['Non_unique'] == '0')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether inline edited value can be truncated or not,
|
||||
@ -2360,41 +2339,25 @@ function PMA_hasPrimaryKeyOrUniqueKey($db, $table)
|
||||
* @param string $db Database name
|
||||
* @param string $table Table name
|
||||
* @param string $column_name Column name
|
||||
* @param string $column_value Edited column value
|
||||
* @param array $column_meta_data Column meta data
|
||||
* @param array &$extra_data Extra data for ajax response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_verifyWhetherValueCanBeTruncatedAndAppendExtraData(
|
||||
$db, $table, $column_name, $column_value, $column_meta_data, &$extra_data
|
||||
$db, $table, $column_name, &$extra_data
|
||||
) {
|
||||
|
||||
$extra_data['isNeedToRecheck'] = true;
|
||||
$extra_data['hasUniqueIdentifier'] = PMA_hasPrimaryKeyOrUniqueKey($db, $table)
|
||||
? true
|
||||
: false;
|
||||
|
||||
// If table has unique identifier (primary/unique key), fetch the value
|
||||
// of the field.
|
||||
if ($extra_data['hasUniqueIdentifier']) {
|
||||
|
||||
$sql_for_real_value = 'SELECT '. PMA_Util::backquote($table) . '.'
|
||||
. PMA_Util::backquote($column_name)
|
||||
. ' FROM ' . PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table)
|
||||
. ' WHERE ' . $_REQUEST['where_clause'][0];
|
||||
|
||||
$sql_for_real_value = 'SELECT '. PMA_Util::backquote($table) . '.'
|
||||
. PMA_Util::backquote($column_name)
|
||||
. ' FROM ' . PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table)
|
||||
. ' WHERE ' . $_REQUEST['where_clause'][0];
|
||||
|
||||
if (PMA_DBI_fetch_value($sql_for_real_value) !== false) {
|
||||
$extra_data['truncatableFieldValue'] = PMA_DBI_fetch_value($sql_for_real_value);
|
||||
} else {
|
||||
$extra_data['isNeedToRecheck'] = false;
|
||||
}
|
||||
|
||||
if (PMA_DBI_fetch_value($sql_for_real_value) !== false) {
|
||||
$extra_data['truncatableFieldValue'] = PMA_DBI_fetch_value($sql_for_real_value);
|
||||
} else {
|
||||
// If there is no unique identifier to the table,
|
||||
// it's not a good idea to recheck since there can be
|
||||
// several results matching for where clause
|
||||
$extra_data['isNeedToRecheck'] = false;
|
||||
}
|
||||
|
||||
|
||||
@ -349,11 +349,9 @@ if ($response->isAjax() && ! isset($_POST['ajax_page_request'])) {
|
||||
// Need to check the inline edited value can be truncated by MySQL
|
||||
// without informing while saving
|
||||
$column_name = $_REQUEST['fields_name']['multi_edit'][0][0];
|
||||
$column_value = $_REQUEST['fields']['multi_edit'][0][0];
|
||||
$column_meta_data = PMA_DBI_get_columns($db, $table, $column_name);
|
||||
|
||||
PMA_verifyWhetherValueCanBeTruncatedAndAppendExtraData(
|
||||
$db, $table, $column_name, $column_value, $column_meta_data, $extra_data
|
||||
$db, $table, $column_name, $extra_data
|
||||
);
|
||||
|
||||
/**Get the total row count of the table*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user