clouding/presto-client-php
最新稳定版本:v1.1.0
Composer 安装命令:
composer require clouding/presto-client-php
包简介
Presto client library for PHP.
README 文档
README
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
<?php 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
<?php $posts = $presto->connection()->query('select * from posts')->get();
If set manager as global, just query directly and get data
<?php $posts = Presto::query('SELECT * FROM posts')->get(); /* [ [1, 'Good pracetice'], [2, 'Make code cleaner'], ] */ $posts = Presto::query('SELECT * FROM posts')->getAssoc(); /* [ ['id' => 1, 'title' => 'Good pracetice'], ['id' => 2, 'title' => 'Make code cleaner'], ] */
Usage
Multiple connections
<?php 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
统计信息
- 总下载量: 13.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-02