ytake/php-presto-client
最新稳定版本:0.1.4
Composer 安装命令:
composer require ytake/php-presto-client
包简介
php prestodb client
关键字:
README 文档
README
prestodb http protocol client for php
What is Presto
Presto is an open source distributed SQL query engine for running interactive analytic queries against data sources of all sizes ranging from gigabytes to petabytes.
Install
required >= PHP 7.0
$ composer require ytake/php-presto-client
Usage
Standard
<?php $client = new \Ytake\PrestoClient\StatementClient( new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'), 'SELECT * FROM acme.acme.acme' ); // execute http request $client->execute(); // next call uri $client->advance(); /** @var \Ytake\PrestoClient\QueryResult $result */ // current result $result = $client->current(); // request cancel $client->cancelLeafStage();
bulk operations
<?php $client = new \Ytake\PrestoClient\StatementClient( new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'), 'SELECT * FROM acme.acme.acme' ); $resultSession = new \Ytake\PrestoClient\ResultsSession($client); // yield results instead of returning them. Recommended. $result = $resultSession->execute()->yieldResults(); // array $result = $resultSession->execute()->getResults();
Fetch Styles
FixData Object
<?php $client = new \Ytake\PrestoClient\StatementClient( new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'), 'SELECT * FROM acme.acme.acme' ); $resultSession = new \Ytake\PrestoClient\ResultsSession($client); $result = $resultSession->execute()->yieldResults(); /** @var \Ytake\PrestoClient\QueryResult $row */ foreach ($result as $row) { foreach ($row->yieldData() as $yieldRow) { if ($yieldRow instanceof \Ytake\PrestoClient\FixData) { var_dump($yieldRow->offsetGet('column_name'), $yieldRow['column_name']); } } }
Array Keys
<?php $client = new \Ytake\PrestoClient\StatementClient( new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'), 'SELECT * FROM acme.acme.acme' ); $resultSession = new \Ytake\PrestoClient\ResultsSession($client); $result = $resultSession->execute()->yieldResults(); /** @var \Ytake\PrestoClient\QueryResult $row */ foreach ($result as $row) { /** @var array $item */ foreach ($row->yieldDataArray() as $item) { if (!is_null($item)) { var_dump($item); } } }
Mapping Class
<?php class Testing { private $_key; private $_value; } $client = new \Ytake\PrestoClient\StatementClient( new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'), 'SELECT * FROM acme.acme.acme' ); $resultSession = new \Ytake\PrestoClient\ResultsSession($client); $result = $resultSession->execute()->yieldResults(); /** @var \Ytake\PrestoClient\QueryResult $row */ foreach ($result as $row) { foreach($row->yieldObject(Testing::class) as $object) { if ($object instanceof Testing) { var_dump($object); } } }
统计信息
- 总下载量: 34.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-06-19