if (!$_GET['database']) { $file = "js/hiveudfs.txt"; $array = file($file); } else { if (!$_GET['table']) { $file = "js/hiveudfs.txt"; $array = file($file); } else { $transport = new TSocket(HOST, PORT); $protocol = new TBinaryProtocol($transport); $client = new ThriftHiveClient($protocol); $transport->open(); $client->execute('use ' . $_GET['database']); $sql = "desc " . $_GET['table']; $client->execute($sql); $array_desc_table = $client->fetchAll(); $i = 0; while ('' != @$array_desc_table[$i]) { $array_desc = explode(' ', $array_desc_table[$i]); $array_desc_desc[$i] = $array_desc[0]; $i++; } $array_table = array($_GET['table']); $file = "js/hiveudfs.txt"; $array = file($file); $array = array_merge($array, $array_desc_desc); $array = array_merge($array, $array_table); } } foreach ($array as $key => $value) { $str .= trim($value) . "\n";
include_once 'templates/style.css'; $transport = new TSocket(HOST, PORT); $protocol = new TBinaryProtocol($transport); $client = new ThriftHiveClient($protocol); $transport->open(); $hql = $_GET['sql']; if (substr($hql, -1) == ";") { $hql = substr($hql, 0, -1); } $hql = "EXPLAIN EXTENDED " . $hql; echo "<br>"; echo "<center><input type=button value=\"Close Window\" onclick='window.close()'></center>"; echo "<hr>"; try { $res = $client->execute($hql); $array = $client->fetchAll(); foreach ($array as $k => $v) { $echo .= str_replace(" ", " ", $v) . "<br />"; } echo "<font color=red>HQL Syntax OK!!!<br><br></font>"; echo $echo; } catch (Exception $e) { $echo = $e->getMessage(); $tmp = explode("FAILED", $echo); $echo = $tmp[0] . "FAILED <font color=red>" . $tmp[1] . "<font>"; echo "Exception: " . $echo; } echo "<hr>"; echo "<center><input type=button value=\"Close Window\" onclick='window.close()'></center>"; //echo 'Field Schemas: '.$status->fieldSchemas.'<br />'; //echo 'Properties: '.$status->properties.'<br />';
exit; } mysql_connect("localhost", "root", "123456"); mysql_select_db("biglaw"); $sql = "select number from cache WHERE keyword = '" . $keyword . "'"; $query = mysql_query($sql); $rows = mysql_num_rows($query); if ($rows == 0) { $transport = new TSocket("localhost", 10000); $protocol = new TBinaryProtocol($transport); $client = new ThriftHiveClient($protocol); $transport->open(); //show tables //$client->execute('select * from `BigLaw` WHERE `mcase` like '.$keyword.' or mcontext like '.$keyword.' or mcourt like '.$keyword.' or mnumber like '.$keyword.' or mtype like '.$keyword); $client->execute('select key from `BigLaw` WHERE `mcontext` like "%' . $keyword . '%"'); $rows = $client->fetchAll(); $result = array(); foreach ($rows as $row) { $result[] = $row; $sql = "insert into `cache`(`keyword`,`number`) values('" . $keyword . "' , '" . $row . "') ;"; mysql_query($sql); /*echo "<fieldset>"; print_r( str_replace( '\n' , "<br />" ,$row )); echo "<br />"; echo "</fieldset>";*/ } echo json_encode($result); } else { $result = array(); while ($data = mysql_fetch_array($query)) { $result[] = $data['number'];
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // set THRIFT_ROOT to php directory of the hive distribution $GLOBALS['THRIFT_ROOT'] = '/lib/php/'; // load the required files for connecting to Hive require_once $GLOBALS['THRIFT_ROOT'] . 'packages/hive_service/ThriftHive.php'; require_once $GLOBALS['THRIFT_ROOT'] . 'transport/TSocket.php'; require_once $GLOBALS['THRIFT_ROOT'] . 'protocol/TBinaryProtocol.php'; // Set up the transport/protocol/client $transport = new TSocket('localhost', 10000); $protocol = new TBinaryProtocol($transport); $client = new ThriftHiveClient($protocol); $transport->open(); // run queries, metadata calls etc $client->execute('SELECT * from src'); var_dump($client->fetchAll()); $transport->close();
if (!@$_GET['database']) { die($lang['dieDatabaseChoose']); } else { $transport = new TSocket(HOST, PORT); $protocol = new TBinaryProtocol($transport); $client = new ThriftHiveClient($protocol); $transport->open(); $client->execute('use ' . $_GET['database']); echo '<div class="container">'; echo '<div class="span10">'; if (!@$_GET['table']) { die($lang['dieTableChoose']); } else { $sql = "desc formatted " . $_GET['table']; $client->execute($sql); $arr = $client->fetchAll(); $arr = $etc->GetTableDetail($arr, "2"); $j = 0; foreach ($arr as $k => $v) { $array_desc = explode(':', $v); $array_desc_desc['key'][$j] = trim($array_desc[0]); $array_desc_desc['value'][$j] = trim($array_desc[1]); if ($array_desc_desc['value'][$j] == 'MANAGED_TABLE' || $array_desc_desc['value'][$j] == 'INDEX_TABLE') { $tmp['key'] = $array_desc_desc['key'][$j]; $tmp['value'] = $array_desc_desc['value'][$j]; } $j++; } if ($tmp['value'] != "MANAGED_TABLE" && $tmp['value'] != "INDEX_TABLE") { die('<script>alert("' . $lang['notExternalTable'] . '");history.back();</script>'); } else {