PHP TDEngine RESTful connector

Related tags

Strings php tdengine
Overview

tdengine-restful-connector

Latest Version GitHub Workflow Status (branch) Php Version License

简介

封装了 TDEngine 的 RESTful 接口,可以使用 PHP 轻松地操作 TDEngine 的数据插入和查询了。

此项目支持在 PHP >= 7.0 的项目中使用。

支持在 ThinkPHP、Laravel、Swooleimi 等项目中使用

在 Swoole 环境中支持协程化,不会阻塞!

技术支持 QQ 群: 17916227点击加群,如有问题可以及时解答和修复。

安装

composer require yurunsoft/tdengine-restful-connector

使用

$client = new \Yurun\TDEngine\Client(new \Yurun\TDEngine\ClientConfig([
    // 'host'            => '127.0.0.1',
    // 'hostName'        => '',
    // 'port'            => 6041,
    // 'user'            => 'root',
    // 'password'        => 'taosdata',
    // 'ssl'             => false,
    // 'timestampFormat' => \Yurun\TDEngine\Constants\TimeStampFormat::LOCAL_STRING,
    // 'keepAlive'       => true,
]));

// 通过 sql 方法执行 sql 语句
var_dump($client->sql('create database if not exists db_test'));
var_dump($client->sql('show databases'));
var_dump($client->sql('create table if not exists db_test.tb (ts timestamp, temperature int, humidity float)'));
var_dump($client->sql(sprintf('insert into db_test.tb values(%s,%s,%s)', time() * 1000, mt_rand(), mt_rand() / mt_rand())));

$result = $client->sql('select * from db_test.tb');

$result->getResponse(); // 获取接口原始返回数据

// 获取列数据
foreach ($result->getColumns() as $column)
{
    $column->getName(); // 列名
    $column->getType(); // 列类型值
    $column->getTypeName(); // 列类型名称
    $column->getLength(); // 类型长度
}

// 获取数据
foreach ($result->getData() as $row)
{
    echo $row['列名']; // 经过处理,可以直接使用列名获取指定列数据
}

$result->getStatus(); // 告知操作结果是成功还是失败;同接口返回格式

$result->getHead(); // 表的定义,如果不返回结果集,则仅有一列“affected_rows”。(从 2.0.17 版本开始,建议不要依赖 head 返回值来判断数据列类型,而推荐使用 column_meta。在未来版本中,有可能会从返回值中去掉 head 这一项。);同接口返回格式

$result->getRow(); // 表明总共多少行数据;同接口返回格式
You might also like...
ColorJizz is a PHP library for manipulating and converting colors.

#Getting started: ColorJizz-PHP uses the PSR-0 standards for namespaces, so there should be no trouble using with frameworks like Symfony 2. ###Autolo

🔡 Portable ASCII library - performance optimized (ascii) string functions for php.

🔡 Portable ASCII Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

:clamp: HtmlMin: HTML Compressor and Minifier via PHP

🗜️ HtmlMin: HTML Compressor and Minifier for PHP Description HtmlMin is a fast and very easy to use PHP library that minifies given HTML5 source by r

Generate Heroku-like random names to use in your php applications.

HaikunatorPHP Generate Heroku-like random names to use in your PHP applications. Installation composer require atrox/haikunator Usage Haikunator is p

Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP

Patchwork UTF-8 for PHP Patchwork UTF-8 gives PHP developpers extensive, portable and performant handling of UTF-8 and grapheme clusters. It provides

PHP library to parse urls from string input

Url highlight - PHP library to parse URLs from string input. Works with complex URLs, edge cases and encoded input. Features: Replace URLs in string b

A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.

SqlFormatter A lightweight php class for formatting sql statements. It can automatically indent and add line breaks in addition to syntax highlighting

:accept: Stringy - A PHP string manipulation library with multibyte support, performance optimized

🉑 Stringy A PHP string manipulation library with multibyte support. Compatible with PHP 7+ 100% compatible with the original "Stringy" library, but t

Paranoid text spacing in PHP

pangu.php Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width charac

Comments
  • WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 976 producers will be discarded

    WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 976 producers will be discarded

     [Coroutine-1970]
    --------------------------------------------------------------------
    #0  Swoole\Coroutine\Channel->push() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole/SwooleHttpConnectionPool.php:97]
    #1  Yurun\Util\YurunHttp\Handler\Swoole\SwooleHttpConnectionPool->release() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole/SwooleHttpConnectionManager.php:100]
    #2  Yurun\Util\YurunHttp\Handler\Swoole\SwooleHttpConnectionManager->release() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php:404]
    #3  Yurun\Util\YurunHttp\Handler\Swoole->recvDefer() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php:227]
    #4  Yurun\Util\YurunHttp\Handler\Swoole->send() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp.php:117]
    #5  Yurun\Util\YurunHttp::send() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/HttpRequest.php:977]
    #6  Yurun\Util\HttpRequest->send() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/HttpRequest.php:1036]
    #7  Yurun\Util\HttpRequest->post() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-restful-connector/src/Client.php:63]
    #8  Yurun\TDEngine\Client->request() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-restful-connector/src/Client.php:99]
    #9  Yurun\TDEngine\Client->sql() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/ClientHandler/Restful/Handler.php:18]
    #10 Yurun\TDEngine\Orm\ClientHandler\Restful\Handler->query() called at [/home/www/hyperf-skeleton/app/Service/CreateAlert2.php:23]
    #11 App\Service\CreateAlert2->handle() called at [/home/www/hyperf-skeleton/app/Command/NodeCommand.php:57]
    #12 App\Command\NodeCommand->App\Command\{closure}() called at [/home/www/hyperf-skeleton/vendor/hyperf/utils/src/Functions.php:274]
    #13 call() called at [/home/www/hyperf-skeleton/vendor/hyperf/utils/src/Coroutine.php:62]
    
    use 0.94960713386536 s
    [2022-11-25 02:57:28 @5365.0]   WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 976 producers will be discarded
    
    opened by onlyshow 7
  • WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 976 producers will be discarded

    WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 976 producers will be discarded

     [Coroutine-1970]
    --------------------------------------------------------------------
    #0  Swoole\Coroutine\Channel->push() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole/SwooleHttpConnectionPool.php:97]
    #1  Yurun\Util\YurunHttp\Handler\Swoole\SwooleHttpConnectionPool->release() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole/SwooleHttpConnectionManager.php:100]
    #2  Yurun\Util\YurunHttp\Handler\Swoole\SwooleHttpConnectionManager->release() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php:404]
    #3  Yurun\Util\YurunHttp\Handler\Swoole->recvDefer() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php:227]
    #4  Yurun\Util\YurunHttp\Handler\Swoole->send() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/YurunHttp.php:117]
    #5  Yurun\Util\YurunHttp::send() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/HttpRequest.php:977]
    #6  Yurun\Util\HttpRequest->send() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/yurun-http/src/HttpRequest.php:1036]
    #7  Yurun\Util\HttpRequest->post() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-restful-connector/src/Client.php:63]
    #8  Yurun\TDEngine\Client->request() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-restful-connector/src/Client.php:99]
    #9  Yurun\TDEngine\Client->sql() called at [/home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/ClientHandler/Restful/Handler.php:18]
    #10 Yurun\TDEngine\Orm\ClientHandler\Restful\Handler->query() called at [/home/www/hyperf-skeleton/app/Service/CreateAlert2.php:23]
    #11 App\Service\CreateAlert2->handle() called at [/home/www/hyperf-skeleton/app/Command/NodeCommand.php:57]
    #12 App\Command\NodeCommand->App\Command\{closure}() called at [/home/www/hyperf-skeleton/vendor/hyperf/utils/src/Functions.php:274]
    #13 call() called at [/home/www/hyperf-skeleton/vendor/hyperf/utils/src/Coroutine.php:62]
    
    use 0.94960713386536 s
    [2022-11-25 02:57:28 @5365.0]   WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 976 producers will be discarded
    
    opened by onlyshow 1
Releases(v2.0.0)
Owner
Yurun
PHP 程序员,imi 框架作者,宇润 PHP 全家桶作者。 我们程序员,外修语言,内修算法。以数据为根,算天算地算自己。 程序员♂♀聚集地Q群:74401592
Yurun
"結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件。 / "Jieba" (Chinese for "to stutter") Chinese text segmentation: built to be the best PHP Chinese word segmentation module.

jieba-php "結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件,目前翻譯版本為 jieba-0.33 版本,未來再慢慢往上升級,效能也需要再改善,請有興趣的開發者一起加入開發!若想使用 Python 版本請前往 fxsjy/jieba 現在已經可以支援繁體中文!只要將字典切換為 bi

Fukuball Lin 1.2k Dec 31, 2022
highlight.php is a server-side syntax highlighter written in PHP that currently supports 185 languages

highlight.php is a server-side syntax highlighter written in PHP that currently supports 185 languages. It's a port of highlight.js by Ivan Sagalaev that makes full use of the language and style definitions of the original JavaScript project.

Geert Bergman 633 Dec 27, 2022
Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Motto: "Every business should have a detection script to detect mobile readers." About Mobile Detect is a lightweight PHP class for detecting mobile d

Şerban Ghiţă 10.2k Jan 4, 2023
A PHP library for generating universally unique identifiers (UUIDs).

ramsey/uuid A PHP library for generating and working with UUIDs. ramsey/uuid is a PHP library for generating and working with universally unique ident

Ben Ramsey 11.9k Jan 8, 2023
👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

Agent A PHP desktop/mobile user agent parser with support for Laravel, based on Mobile Detect with desktop support and additional functionality. Insta

Jens Segers 4.2k Jan 5, 2023
A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.

SqlFormatter A lightweight php class for formatting sql statements. It can automatically indent and add line breaks in addition to syntax highlighting

Jeremy Dorn 3.9k Jan 1, 2023
A PHP string manipulation library with multibyte support

A PHP string manipulation library with multibyte support. Compatible with PHP 5.4+, PHP 7+, and HHVM. s('string')->toTitleCase()->ensureRight('y') ==

Daniel St. Jules 2.5k Jan 3, 2023
A sane interface for php's built in preg_* functions

Making regex great again Php's built in preg_* functions require some odd patterns like passing variables by reference and treating false or null valu

Spatie 1.1k Jan 4, 2023
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

URLify for PHP A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js from the Django project. Handles symbols from

Aband*nthecar 667 Dec 20, 2022
🉑 Portable UTF-8 library - performance optimized (unicode) string functions for php.

?? Portable UTF-8 Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

Lars Moelleken 474 Dec 22, 2022