Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

256 lines (244 sloc) 8.256 kb
<?php
include_once 'config.inc.php';
include_once 'templates/style.css';
if(!@$_GET['database'])
{
die($lang['dieDatabaseChoose']);
}
else
{
$transport = new TSocket(HOST, PORT);
$protocol = new TBinaryProtocol($transport);
$client = new ThriftHiveClient($protocol);
$transport->open();
//$client->execute('add jar '.$env['hive_jar']);
$client->execute('use '.$_GET['database']);
echo '<div class="container">';
if(!@$_GET['table'])
{
die ($lang['dieTableChoose']);
}
else
{
echo "<a href=dbStructure.php?database=".$_GET['database']."><i class=icon-backward></i> ".$lang['back']."</a><br><br>";
if(!@$_POST['submit'])
{
$sql = 'desc formatted '.$_GET['table'];
$client->execute($sql);
$array_desc_table = $client->fetchAll();
//get table description and explode the desc into a multi-dimensional array
//获取表说明,并放入二维数组$array_desc_desc
$etc = new Etc;
$array_desc_table_1 = $etc->GetTableDetail($array_desc_table, "1");
$array_desc_table_4 = @$etc->GetTableDetail($array_desc_table, "4");
$selected = " ";
$type = array('string'=>'String','tinyint'=>'Tiny int(3)','smallint'=>'Small int(5)','int'=>'Int(10)','bigint'=>'Big int(19)','double'=>'Double',
//'map'=>'Map','structs'=>'Structs','arrays'=>'Arrays',
'float'=>'Float','boolean'=>'Boolean');
$i = 0;
while ('' != @$array_desc_table_1[$i])
{
$array_desc_1 = explode(' ',$array_desc_table_1[$i]);
$array_desc_desc_1[$i]['name'] = $array_desc_1[0];
$array_desc_desc_1[$i]['type'] = $array_desc_1[1];
$array_desc_desc_1[$i]['comment'] = $array_desc_1[2];
$i++;
}
echo $lang['alterTableWarning'];
echo "<form method=post>";
echo "<table class=\"table table-bordered table-condensed\">";
echo "<tr class=error>";
echo "<td>".$lang['renameTable']."</td><td><input type=text name=new_table_name value=".$_GET['table']."></td>";
echo "</tr>";
echo "</table><br><br>";
echo '<table class="table table-bordered table-condensed table-striped">';
echo "<tr class=info>
<td>".$lang['dropTable']."</td>
<td>".$lang['fieldName']."</td>
<td>".$lang['fieldType']."</td>
<td>".$lang['comment']."</td>
</tr>";
$i = 0;
foreach ($array_desc_desc_1 as $key => $value)
{
echo '<tr>';
foreach($value as $k => $v)
{
//echo '<tr '.$color.'>';
//echo '<td>';
if($k == 'name')
{
echo "<td>";
echo "<a class=\"btn btn-danger\" href=# onclick=\"javascript:realconfirm('".$lang['dropColumnConfirm']."','dropColumn.php?database=".$_GET['database']."&table=".$_GET['table']."&column=".$v."');return false;\"><i class=icon-remove></i>".$lang['dropTable']."</a>";
echo "</td>";
}
if($k == 'type')
{
echo "<td>";
//echo $v."<br>";
echo "<select name=field_type[]>";
foreach($type as $kk => $vv)
{
if ($v == $kk)
{
$selected = "selected";
}
else
{
$selected ="";
}
echo "<option value=".$kk." ".$selected.">".$vv."</option>";
}
echo "</select>";
echo "</td>";
}
if($k == 'name')
{
echo "<td>";
echo "<input type=text name=field_name[] value=".$v.">\n";
echo "<input type=hidden name=old_field_name[] value=".$v.">\n";
echo "</td>";
}
if($k == 'comment')
{
echo "<td>";
echo "<input type=text name=comment[] value=".$v.">\n";
//echo "<input type=text name=old_comment[] value=".$v.">\n";
echo "</td>";
}
//echo '</td>';
//echo '</tr>';
}
echo '</tr>';
$i++;
}
echo '</table><br>';
############################################################################################
if($array_desc_table_4[0] != "")
{
$i = 0;
while ('' != @$array_desc_table_4[$i])
{
$array_desc_4 = explode(' ',$array_desc_table_4[$i]);
$array_desc_desc_4[$i]['name'] = $array_desc_4[0];
$array_desc_desc_4[$i]['type'] = $array_desc_4[1];
$array_desc_desc_4[$i]['comment'] = $array_desc_4[2];
$i++;
}
echo '<table class="table table-bordered table-condensed">';
echo "<tr class=info>
<td>".$lang['dropTable']."</td>
<td>".$lang['partitionName']."</td>
<td>".$lang['partitionName']."</td>
<td>".$lang['comment']."</td>
</tr>";
$i = 0;
foreach ($array_desc_desc_4 as $key => $value)
{
echo '<tr>';
foreach($value as $k => $v)
{
//echo '<tr '.$color.'>';
//echo '<td>';
if($k == 'name')
{
echo "<td>";
echo "<!--<a href=# onclick=\"javascript:realconfirm('".$lang['dropColumnConfirm']."','dropPartition.php?database=".$_GET['database']."&table=".$_GET['table']."&column=".$v."');return false;\"><img src=images/b_drop.png>".$lang['dropTable']."</a>-->";
echo "</td>";
}
if($k == 'type')
{
echo "<td>";
//echo $v."<br>";
echo "<select name=partition_type[] disabled>";
foreach($type as $kk => $vv)
{
if ($v == $kk)
{
$selected = "selected";
}
else
{
$selected ="";
}
echo "<option value=".$kk." ".$selected.">".$vv."</option>";
}
echo "</select>";
echo "</td>";
}
if($k == 'name')
{
echo "<td>";
echo "<input type=text name=partition_name[] value=".$v." disabled>\n";
echo "<input type=hidden name=old_partition_name[] value=".$v." disabled>\n";
echo "</td>";
}
if($k == 'comment')
{
echo "<td>";
echo "<input type=text name=partition_comment[] value=".$v." disabled>\n";
//echo "<input type=text name=old_comment[] value=".$v.">\n";
echo "</td>";
}
//echo '</td>';
//echo '</tr>';
}
echo '</tr>';
$i++;
}
echo '</table><br>';
}
echo '<input type=hidden name=database value='.$_GET['database'].'><input type=hidden name=table value='.$_GET['table'].'>';
echo '<input class="btn btn-danger" type=submit name=submit value='.$lang['submit'].'>';
echo "&nbsp;&nbsp;";
echo "<input type=button class=\"btn btn-success\" value=".$lang['cancel']." onclick=\"javascript:history.back();\">";
echo "&nbsp;&nbsp;";
echo "</form>";
echo "<br><br>";
#------------------------add columns form-------------
include_once "templates/add_columns.html";
#-----------------------------------------------------
#------------------------add partitions form-------------
#include_once "templates/add_partitions.html";
#-----------------------------------------------------
}
else
{
if(!@$_POST['confirm'])
{
//var_dump($_POST['field_name']);var_dump($_POST['field_type']);
$i = 0;
echo "<form name=confirm method=post>";
echo $sql = "ALTER TABLE `".$_POST['table']."` RENAME TO `".$_POST['new_table_name']."`";
echo "<input type=hidden name=sql[] value=\"".$sql."\">";
echo "<br><br>";
while ($i < count($_POST['field_type']))
{
$sql = "ALTER TABLE `".$_POST['new_table_name']."` CHANGE `".$_POST['old_field_name'][$i]."` `".$_POST['field_name'][$i]."` ".$_POST['field_type'][$i]." COMMENT '".$_POST['comment'][$i]."'";
echo "<br>";
echo $sql;
echo "<input type=hidden name=sql[] value=\"".$sql."\">";
$i++;
}
echo "<input type=hidden name=confirm value=1><br>";
echo "<input type=hidden name=table value=".$_POST['table'].">";
echo "<input type=hidden name=database value=".$_POST['database'].">";
echo $lang['sure']."<br>";
echo "<input class=\"btn btn-danger\" type=submit name=submit value=".$lang['submit'].">";
echo "<input class=\"btn btn-success\" type=button name=cancel value=".$lang['cancel']." onclick=\"window.location='index.php?frame=right'\">";
echo "</form>";
}
else
{
foreach ($_POST['sql'] as $k => $v)
{
echo @$client->execute($v);
}
echo "<script>alert('".$lang['success']."');showsd('tableList.php?database=".$_POST['database']."','dbStructure.php?database=".$_POST['database']."');</script>";
}
}
}
echo '</div>';
$transport->close();
}
?>
Jump to Line
Something went wrong with that request. Please try again.