'.$lang['L_SQL_TABLESOFDB'].' `'.$databases['Name'][$dbid].'` '.$lang['L_SQL_EDIT'].''; //Primaerschluessel loeschen if (isset($_GET['killPrimaryKey'])) { $keys=getPrimaryKeys($databases['Name'][$dbid],$_GET['tablename']); //Zu loeschenden Schluessel aus dem Array entfernen $keyPos=array_search($_GET['killPrimaryKey'],$keys['name']); if (!(false===$keyPos)) { unset($keys['name'][$keyPos]); unset($keys['size'][$keyPos]); $keys['name']=array_values($keys['name']); $keys['size']=array_values($keys['size']); $res=setNewPrimaryKeys($databases['Name'][$dbid], $_GET['tablename'], $keys['name'], $keys['size']); if ($res) { echo ''; } else { echo ''; } } else { echo ''; } } //Primärschlüssel löschen ende //Neue Schlüssel setzen if (isset($_POST['setNewKeys'])) { $fields=getAllFields($databases['Name'][$dbid],$_GET['tablename']); $newKeysArray=Array(); $newKeySizesArray=Array(); foreach ($fields as $index=>$field) { if ((isset($_POST["setNewKey".$index]))&&($_POST["setNewKey".$index]!="")) { $newKeysArray[]=$_POST["setNewKey".$index]; $newKeySizesArray[]=isset($_POST["indexSize".$index]) ? (int) $_POST["indexSize".$index]:''; } } //doppelte Elemente entfernen $newKeysArray=array_unique($newKeysArray); $newKeySizesArray=array_intersect_key($newKeySizesArray, $newKeysArray); if ($_POST["indexType"]=="primary") { $res=setNewPrimaryKeys($databases['Name'][$dbid], $_GET['tablename'], $newKeysArray, $newKeySizesArray); if ($res) { echo ''; } else { echo ''; } } else { if ($_POST["indexType"]=="unique") { $newIndexType="UNIQUE"; } elseif ($_POST["indexType"]=="fulltext") { $newIndexType="FULLTEXT"; } else { $newIndexType="INDEX"; } $res=setNewKeys($databases['Name'][$dbid], $_GET['tablename'], $newKeysArray, $newIndexType, $_POST['indexName'], $newKeySizesArray); if ($res) { echo ''; } else { echo ''; } } } //Andere Indizes löschen if (isset($_GET['killIndex'])) { $res = killKey($databases['Name'][$dbid], $_GET['tablename'], $_GET['killIndex']); if ($res) { echo ''; } else { echo ''; } } if (isset($_GET['kill'])) { if ($_GET['anz']==1) echo '
'.$lang['L_SQL_NOFIELDDELETE'].'
'; else { $sql_alter="ALTER TABLE `".$databases['Name'][$dbid]."`.`".$_GET['tablename']."` DROP COLUMN `".$_GET['kill']."`"; $res = MSD_DoSQL($sql_alter); if ($res) { echo ''.$lang['L_SQL_FIELDDELETE1'].' `'.$_GET['kill'].'` '.$lang['L_SQL_DELETED'].'.
'.highlight_sql($out).''.$lang['L_SQL_NODEST_COPY'].'
'; } elseif (Table_Exists($databases['Name'][$dbid],$_POST['tablecopyname'])) { echo ''.$lang['L_SQL_DESTTABLE_EXISTS'].'
'; } else { Table_Copy("`".$databases['Name'][$dbid]."`.`".$table_edit_name."`",$_POST['tablecopyname'],$_POST['copyatt']); echo ''.sprintf($lang['L_SQL_SCOPY'],$table_edit_name,$_POST['tablecopyname']).'
' : sprintf($lang['L_SQL_TCOPY'],$table_edit_name,$_POST['tablecopyname']).''; echo highlight_sql($out).''.$lang['L_SQL_TABLENONAME'].'
'; } else { $sql_alter="CREATE TABLE `".$databases['Name'][$dbid]."`.`".$_POST['newtablename']."` (`id` int(11) unsigned not null AUTO_INCREMENT PRIMARY KEY ) ".((MSD_NEW_VERSION) ? "ENGINE" : "TYPE")."=MyISAM;"; $res = MSD_DoSQL($sql_alter); if ($res) { echo SQLOutput($out,$lang['L_TABLE'].' `'.$_POST['newtablename'].'` '.$lang['L_SQL_CREATED']); } } } if (isset($_POST['t_edit_submit'])) { $sql_alter="ALTER TABLE `".$databases['Name'][$dbid]."`.`".$_POST['table_edit_name']."` "; if ($_POST['t_edit_name']=="") echo ''.$lang['L_SQL_TBLNAMEEMPTY'].'
'; elseif (MSD_NEW_VERSION&&$_POST['t_edit_collate']!=""&&substr($_POST['t_edit_collate'],0,strlen($_POST['t_edit_charset']))!=$_POST['t_edit_charset']) echo ''.$lang['L_SQL_COLLATENOTMATCH'].'
'; else { if ($_POST['table_edit_name']!=$_POST['t_edit_name']) { $sql_alter.="RENAME TO `".$_POST['t_edit_name']."`, "; $table_edit_name=$_POST['t_edit_name']; } else $table_edit_name=$_POST['table_edit_name']; if ($_POST['t_edit_engine']!="") $sql_alter.=((MSD_NEW_VERSION) ? "ENGINE=" : "TYPE=").$_POST['t_edit_engine'].", "; if ($_POST['t_edit_rowformat']!="") $sql_alter.="ROW_FORMAT=".$_POST['t_edit_rowformat'].", "; if (MSD_NEW_VERSION&&$_POST['t_edit_charset']!="") $sql_alter.="DEFAULT CHARSET=".$_POST['t_edit_charset'].", "; if (MSD_NEW_VERSION&&$_POST['t_edit_collate']!="") $sql_alter.="COLLATE ".$_POST['t_edit_collate'].", "; $sql_alter.="COMMENT='".$_POST['t_edit_comment']."' "; $res = MSD_DoSQL($sql_alter); if ($res) { echo SQLOutput($out,$lang['L_TABLE'].' `'.$_POST['table_edit_name'].'` '.$lang['L_SQL_CHANGED']); } } } else { if (!isset($table_edit_name)||$table_edit_name=="") { $table_edit_name=(isset($_GET['tablename'])) ? $_GET['tablename'] : ""; if (isset($_POST['tableselect'])) $table_edit_name=$_POST['tableselect']; if (isset($_POST['newtablesubmit'])) $table_edit_name=$_POST['newtablename']; } } if (isset($_POST['newfield_posted'])) { //build sql for alter if ($_POST['f_name']=='') { echo ''.$lang['L_SQL_FIELDNAMENOTVALID'].' ('.$_POST['f_name'].')
'; $field_fehler=1; } else { //alter Key $oldkeys[0]=$_POST['f_primary']; $oldkeys[1]=$_POST['f_unique']; $oldkeys[2]=$_POST['f_index']; $oldkeys[3]=$_POST['f_fulltext']; //neuer Key $newkeys[0]=($_POST['f_index_new']=="primary") ? 1 : 0; $newkeys[1]=($_POST['f_index_new']=="unique") ? 1 : 0; $newkeys[2]=($_POST['f_index_new']=="index") ? 1 : 0; $newkeys[3]=(isset($_POST['f_indexfull'])) ? 1 : 0; $add_sql.=ChangeKeys($oldkeys,$newkeys,$_POST['f_name'],$_POST['f_size'],"drop_only"); $sql_stamm="ALTER TABLE `".$databases['Name'][$dbid]."`.`$table_edit_name` "; $sql_alter=$sql_stamm.((isset($_POST['editfield'])) ? "CHANGE COLUMN `".$_POST['fieldname']."` `".$_POST['f_name']."` " : "ADD COLUMN `".$_POST['f_name']."` "); $sql_alter.=$_POST['f_type']; $wl=stripslashes($_POST['f_size']); if ($wl!=""&&!preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i',$_POST['f_type'])) { $sql_alter.="($wl) "; } elseif ($_POST['f_size']==""&&preg_match('@^(VARCHAR)$@i',$_POST['f_type'])) { $sql_alter.="("."255".") "; } else $sql_alter.=" "; $sql_alter.=$_POST['f_attribut']." "; $sql_alter.=$_POST['f_null']." "; $sql_alter.=($_POST['f_default']!="") ? "DEFAULT '".addslashes($_POST['f_default'])."' " : ""; if (MSD_NEW_VERSION&&$_POST['f_collate']!="") $sql_alter.="COLLATE ".$_POST['f_collate']." "; if ($_POST['f_extra']=="AUTO_INCREMENT") { $sql_alter.=" AUTO_INCREMENT "; } $sql_alter.=$_POST['f_position']; if ($newkeys[0]==1) $sql_alter.=", ADD PRIMARY KEY (`".$_POST['f_name']."`)"; if ($newkeys[1]==1) $sql_alter.=", ADD UNIQUE (`".$_POST['f_name']."`)"; if ($newkeys[2]==1) $sql_alter.=", ADD INDEX (`".$_POST['f_name']."`)"; if ($newkeys[3]==1) $sql_alter.=", ADD FULLTEXT INDEX (`".$_POST['f_name']."`)"; $sql_alter.=";"; if ($add_sql!="") { $add_sql=$sql_stamm.$add_sql; $sql_alter="$sql_alter\n$add_sql;"; } $res = MSD_DoSQL($sql_alter); if ($res) { echo '`'.$_POST['f_name'].'` '.((isset($_POST['editfield'])) ? $lang['L_SQL_CHANGED'] : $lang['L_SQL_CREATED']).'
'; echo highlight_sql($out).''; if ($table_edit_name!="") { $sqlf="SHOW FULL FIELDS FROM `".$databases['Name'][$dbid]."`.`$table_edit_name` ;"; $res=MSD_query($sqlf); $anz_fields=mysql_num_rows($res); $fields_infos=getFieldinfos($databases['Name'][$dbid],$table_edit_name); if (MSD_NEW_VERSION) $t_engine=(isset($fields_infos['_tableinfo_']['ENGINE'])) ? $fields_infos['_tableinfo_']['ENGINE'] : "MyISAM"; else $t_engine=(isset($fields_infos['_tableinfo_']['TYPE'])) ? $fields_infos['_tableinfo_']['TYPE'] : "MyISAM"; $t_charset=(isset($fields_infos['_tableinfo_']['DEFAULT CHARSET'])) ? $fields_infos['_tableinfo_']['DEFAULT CHARSET'] : ""; $t_collation=isset($row['Collation']) ? $row['Collation'] : ""; //(isset($fields_infos['_tableinfo_']['COLLATE'])) ? $fields_infos['_tableinfo_']['COLLATE'] : ""; $t_comment=(isset($fields_infos['_tableinfo_']['COMMENT'])) ? substr($fields_infos['_tableinfo_']['COMMENT'],1,strlen($fields_infos['_tableinfo_']['COMMENT'])-2) : ""; $t_rowformat=(isset($fields_infos['_tableinfo_']['ROW_FORMAT'])) ? $fields_infos['_tableinfo_']['ROW_FORMAT'] : ""; echo "
'; $field_fehler=0; echo '
'; } else echo ''.$lang['L_SQL_INSERTNEWFIELD'].'
'.$lang['L_NAME'].' | '.$lang['L_SQL_COLUMNS'].' | '.$lang['L_INFO_SIZE'].' | '.((MSD_NEW_VERSION) ? ''.$lang['L_TABLE_TYPE'].' | ' : '').''.$lang['L_SQL_ALLOWDUPS'].' | '.$lang['L_SQL_CARDINALITY'].' | '.$lang['L_COMMENT'].' | ||
---|---|---|---|---|---|---|---|---|
'.$lang['L_SQL_TABLENOINDEXES'].' | ||||||||
'; if ($row['Key_name']=="PRIMARY") { echo ''; echo ''; echo ''; } else { echo ''; echo ''; echo ''; } echo ' | '; echo ''.($i+1).'. | '; echo ''.$row['Key_name'].' | '; echo ''.$row['Column_name'].' | '; echo ''; if (isset($row['Sub_part']) && $row['Sub_part']>0) echo $row['Sub_part']; echo ' | '; if (MSD_NEW_VERSION) echo ''.$row['Index_type'].' | '; echo ''.(($row['Non_unique']==1) ? $lang['L_YES'] : $lang['L_NO']).' | '; echo ''.(($row['Cardinality']>=0) ? $row['Cardinality'] : $lang['L_NO']).' | '; echo ''.$row['Comment'].' | '; echo '