1. Go to this page and download the library: Download ytake/php-presto-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ytake / php-presto-client example snippets
$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();
$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();
$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']);
}
}
}
$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);
}
}
}
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);
}
}
}
bash
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.