Skip to content
A Presto client for the PHP programming language.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitattributes
.gitignore
.travis.yml
LICENSE.md Rename LICENSE to LICENSE.md Mar 23, 2019
README.md
composer.json
phpcs.xml
phpstan.neon
phpunit.xml.dist

README.md

Presto Client PHP

PHPStan

A Presto client for the PHP programming language.

Inspired by illuminate/database

Features

  • Multiple connections define.
  • Get result as an associative array.

Installation

composer require clouding/presto-client-php

Quick Start

Create a presto manager

use Clouding\Presto\Presto;

$presto = new Presto();

$presto->addConnection([
    'host' => 'localhost:8080',
    'catalog' => 'default',
    'schema' => 'presto',
]);

// Set manager as global (optional)
$presto->setAsGlobal();

Get a default connection and send query

$posts = $presto->connection()->query('select * from posts')->get();

If set manager as global, just query directly and get data with collection

$posts = Presto::query('SELECT * FROM posts')->get();
$posts->toArray(); 

/* 
    [
        [1, 'Good pracetice'],
        [2, 'Make code cleaner'],
    ]
*/

$posts = Presto::query('SELECT * FROM posts')->getAssoc();
$posts->toArray(); 

/* 
    [
        ['id' => 1, 'title' => 'Good pracetice'],
        ['id' => 2, 'title' => 'Make code cleaner'],
    ]
*/    

Usage

Multiple connections

use Clouding\Presto\Presto;

$presto = new Presto();

$presto->addConnection([
    'host' => 'localhost:8080',
    'catalog' => 'default',
    'schema' => 'presto',
]);

$presto->addConnection([
    'host' => 'localhost:8080',
    'catalog' => 'default2',
    'schema' => 'presto2',
], 'presto2');

$presto->setAsGlobal();

// Get connections
$connections = Presto::getConnections();

// Specify connection
$posts = Presto::query('SELECT * FROM posts', 'presto2')->get();

Running Tests

composer test
You can’t perform that action at this time.