ytake / php-presto-client
php prestodb client
Fund package maintenance!
ytake
Installs: 30 189
Dependents: 2
Suggesters: 0
Security: 0
Stars: 17
Watchers: 5
Forks: 5
Open Issues: 2
Requires
- php: >=7.0.0
- ext-curl: *
- fig/http-message-util: ^1.1
- guzzlehttp/guzzle: ^6.2
- psr/log: ~1.0
- ramsey/uuid: ^3.0
Requires (Dev)
- monolog/monolog: ^1.22
- pdepend/pdepend: ^2.2.4
- phploc/phploc: *
- phpmd/phpmd: @stable
- phpunit/phpunit: ~6.0
- satooshi/php-coveralls: *
- sebastian/phpcpd: *
- sensiolabs/security-checker: ^4.0.0
- squizlabs/php_codesniffer: ~2.7
This package is auto-updated.
Last update: 2024-11-20 01:41:58 UTC
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); } } }