/tags/release-0.1-rc2/hive/external/service/src/test/php/test_service.php
PHP | 17 lines | 12 code | 1 blank | 4 comment | 0 complexity | 8a522283b9cef9b0d6aac0d0cb1c7289 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
- <?php
- // 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();