} } } return $type; } if (odbc_exec($client->get_connection(), "COMMIT;") === false) { die(get_odbc_error()); } if (odbc_exec($client->get_connection(), "SET TRANSACTION NAME 'edit_table_fields_transaction';") === false) { die(get_odbc_error()); } $rollback_needed = false; $rollback_error_message = ""; //check if existing fields were not changed //"SELECT column_name, data_type, data_precision, data_length, nullable, CONSTRAINT_TYPE, column_id FROM ALL_TAB_COLUMNS acol LEFT JOIN (select CONSTRAINT_TYPE, COLUMN_NAME as c2 from user_constraints uc inner join USER_IND_COLUMNS cols ON uc.index_name = cols.index_name) ON column_name = c2 where table_name='".strtoupper(totally_escape($target))."' ORDER BY column_id ASC" $colnames = odbc_exec($client->get_connection(), get_columns_info_query(strtoupper($table_name))); $idx = 1; $drop_primary_key = false; $make_unique_fields_list = array(); //"" while (odbc_fetch_row($colnames)) { //odbc_result($colnames, 1) -- column_name //odbc_result($colnames, 2) -- type //odbc_result($colnames, 3) -- precision //odbc_result($colnames, 4) -- length //odbc_result($colnames, 5) //if == N => NOT NULL present (true) //odbc_result($colnames, 6) //constraint type ('P' for primary, 'U' for unique) //TODO: compare with column$idx_* //if name is empty, delete column if (!isset($_POST["column_name"]) || !isset($_POST["column_name"][$idx]) || $_POST["column_name"][$idx] == "") { //echo "drop column ".odbc_result($colnames, 1)."\n"; //debug
var primary = (constraint == 'P'); document.getElementById('column'+index+'_primary').checked = primary; document.getElementById('column'+index+'_primary').value = (primary?'true':'false'); var unique = (constraint == 'U' || constraint == 'P'); document.getElementById('column'+index+'_unique').checked = unique; document.getElementById('column'+index+'_unique').value = (unique?'true':'false'); document.getElementById('column'+index+'_unique').disabled = primary; select_change(index); } <?php if ($target == "") { ?> for(var i=0; i<5; ++i) add_column(); <?php } else { $q = get_columns_info_query($target); $colnames = odbc_exec($client->get_connection(), $q); $idx = 1; while (odbc_fetch_row($colnames)) { echo "\tadd_column();\n"; echo "\tsetup_column(" . $idx . ", \"" . odbc_result($colnames, 1) . "\", \"" . odbc_result($colnames, 2) . "\", \"" . odbc_result($colnames, 3) . "\", \"" . odbc_result($colnames, 4) . "\", \"" . odbc_result($colnames, 5) . "\", \"" . odbc_result($colnames, 6) . "\" == \"N\", \"" . odbc_result($colnames, 7) . "\");\n"; //if == N => NOT NULL present (true) $idx += 1; } } ?> </script>