diff --git a/js/sql.js b/js/sql.js index 14215b49d..fc3a65056 100644 --- a/js/sql.js +++ b/js/sql.js @@ -243,7 +243,7 @@ $(document).ready(function() { // Collect values of all fields to submit, we don't know which changed var params_to_submit = {}; - var relation_fields = new Array(); + var relation_fields = {}; var transform_fields = {}; var transformation_fields = false; @@ -268,7 +268,7 @@ $(document).ready(function() { this_field_params[field_name] = $(this).find('select').val(); if($(this).is('.relation')) { - relation_fields.push(field_name); + $.extend(relation_fields, this_field_params); } } @@ -284,10 +284,8 @@ $(document).ready(function() { sql_query = sql_query.replace(/,\s$/, ''); sql_query += ' WHERE ' + where_clause; - var rel_fields_list = ''; - if(relation_fields.length > 0) { - rel_fields_list = relation_fields.join(); - } + var rel_fields_list = $.param(relation_fields); + var transform_fields_list = $.param(transform_fields); // Make the Ajax post after setting all parameters diff --git a/sql.php b/sql.php index 4bad40020..17320b451 100755 --- a/sql.php +++ b/sql.php @@ -63,8 +63,20 @@ if(isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values $foreignData = PMA_getForeignData($foreigners, $column, false, '', ''); $dropdown = PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $_REQUEST['curr_value'], $cfg['ForeignKeyMaxLimit']); - - $dropdown = ''; + + if( $dropdown == '') { + //Handle the case when number of values is more than $cfg['ForeignKeyMaxLimit'] + $_url_params = array( + 'db' => $db, + 'table' => $table, + 'field' => $column + ); + + $dropdown = 'Search Foreign Data'; + } + else { + $dropdown = ''; + } $extra_data['dropdown'] = $dropdown; PMA_ajaxResponse(NULL, true, $extra_data); @@ -593,10 +605,12 @@ if (0 == $num_rows || $is_affected) { $map = PMA_getForeigners($db, $table, '', 'both'); - $rel_fields = explode(',', $_REQUEST['rel_fields_list']); + $rel_fields = array(); + parse_str($_REQUEST['rel_fields_list'], $rel_fields); - foreach( $rel_fields as $rel_field) { + foreach( $rel_fields as $rel_field => $rel_field_value) { + $where_comparison = '=' . $rel_field_value; $_url_params = array( 'db' => $map[$rel_field]['foreign_db'], 'table' => $map[$rel_field]['foreign_table'],