if (isset($field_fulltext) && is_array($field_fulltext)) { foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) { $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey; } } if (isset($_REQUEST['submit_num_fields'])) { //if adding new fields, set regenerate to keep the original values $regenerate = 1; } $foreigners = PMA_getForeigners($db, $table, '', 'foreign'); $child_references = PMA_getChildReferences($db, $table); for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) { if (!empty($regenerate)) { list($columnMeta, $submit_length, $submit_attribute, $submit_default_current_timestamp, $comments_map, $mime_map) = PMA_handleRegeneration($columnNumber, isset($available_mime) ? $mime_map : null, $comments_map, $mime_map); } elseif (isset($fields_meta[$columnNumber])) { $columnMeta = PMA_getColumnMetaForDefault($fields_meta[$columnNumber], isset($analyzed_sql[0]['create_table_fields'][$fields_meta[$columnNumber]['Field']]['default_value'])); } if (isset($columnMeta['Type'])) { $extracted_columnspec = PMA_Util::extractColumnSpec($columnMeta['Type']); if ($extracted_columnspec['type'] == 'bit') { $columnMeta['Default'] = PMA_Util::convertBitDefaultValue($columnMeta['Default']); } $type = $extracted_columnspec['type']; $length = $extracted_columnspec['spec_in_brackets']; } else { // creating a column $columnMeta['Type'] = ''; $type = ''; $length = ''; $extracted_columnspec = array(); }
/** * Test for PMA_getColumnMetaForDefault * * @return void */ public function testGetColumnMetaForDefault() { $cmeta = array('Default' => null, 'Null' => 'YES', 'DefaultType' => 'a', 'DefaultValue' => 'b'); $result = PMA_getColumnMetaForDefault($cmeta, null); $this->assertEquals('NULL', $result['DefaultType']); $this->assertEquals('', $result['DefaultValue']); // case 2 $cmeta = array('Default' => null, 'Null' => 'NO', 'DefaultType' => 'a', 'DefaultValue' => 'b'); $result = PMA_getColumnMetaForDefault($cmeta, true); $this->assertEquals('USER_DEFINED', $result['DefaultType']); $this->assertEquals(null, $result['DefaultValue']); // case 3 $cmeta = array('Default' => null, 'Null' => 'NO', 'DefaultType' => 'a', 'DefaultValue' => 'b'); $result = PMA_getColumnMetaForDefault($cmeta, false); $this->assertEquals('NONE', $result['DefaultType']); $this->assertEquals(null, $result['DefaultValue']); // case 4 $cmeta = array('Default' => 'CURRENT_TIMESTAMP', 'Null' => 'NO', 'DefaultType' => 'a', 'DefaultValue' => 'b'); $result = PMA_getColumnMetaForDefault($cmeta, false); $this->assertEquals('CURRENT_TIMESTAMP', $result['DefaultType']); $this->assertEquals(null, $result['DefaultValue']); // case 5 $cmeta = array('Default' => 'SOMETHING_ELSE', 'Null' => 'NO', 'DefaultType' => 'a', 'DefaultValue' => 'b'); $result = PMA_getColumnMetaForDefault($cmeta, false); $this->assertEquals('USER_DEFINED', $result['DefaultType']); $this->assertEquals('SOMETHING_ELSE', $result['DefaultValue']); }