{"id":15374297,"url":"https://github.com/yurunsoft/tdengine-restful-connector","last_synced_at":"2025-07-16T01:48:54.850Z","repository":{"id":45567408,"uuid":"386128466","full_name":"Yurunsoft/tdengine-restful-connector","owner":"Yurunsoft","description":"PHP TDEngine RESTful connector","archived":false,"fork":false,"pushed_at":"2023-11-01T02:31:04.000Z","size":21,"stargazers_count":17,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:51:25.800Z","etag":null,"topics":["php","tdengine"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yurunsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-07-15T01:46:50.000Z","updated_at":"2024-12-16T05:36:08.000Z","dependencies_parsed_at":"2024-01-07T13:09:57.601Z","dependency_job_id":null,"html_url":"https://github.com/Yurunsoft/tdengine-restful-connector","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"4a1ea50caf06f22daac65554db62584d1ccfecc5"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2Ftdengine-restful-connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2Ftdengine-restful-connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2Ftdengine-restful-connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2Ftdengine-restful-connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yurunsoft","download_url":"https://codeload.github.com/Yurunsoft/tdengine-restful-connector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249061204,"owners_count":21206467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","tdengine"],"created_at":"2024-10-01T13:58:16.334Z","updated_at":"2025-04-15T11:32:51.581Z","avatar_url":"https://github.com/Yurunsoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tdengine-restful-connector\n\n[![Latest Version](https://poser.pugx.org/yurunsoft/tdengine-restful-connector/v/stable)](https://packagist.org/packages/yurunsoft/tdengine-restful-connector)\n![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/Yurunsoft/tdengine-restful-connector/ci/master)\n[![Php Version](https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg)](https://secure.php.net/)\n[![License](https://img.shields.io/github/license/Yurunsoft/tdengine-restful-connector.svg)](https://github.com/Yurunsoft/tdengine-restful-connector/blob/master/LICENSE)\n\n## 简介\n\n封装了 [TDEngine](https://github.com/taosdata/TDengine) 的 RESTful 接口，可以使用 PHP 轻松地操作 TDEngine 的数据插入和查询了。\n\n此项目支持在 PHP \u003e= 7.1 的项目中使用。\n\n支持在 ThinkPHP、Laravel、[Swoole](https://github.com/swoole/swoole-src)、[imi](https://github.com/imiphp/imi) 等项目中使用\n\n在 Swoole 环境中支持协程化，不会阻塞！\n\n技术支持 QQ 群: 17916227[![点击加群](https://pub.idqqimg.com/wpa/images/group.png \"点击加群\")](https://jq.qq.com/?_wv=1027\u0026k=5wXf4Zq)，如有问题可以及时解答和修复。\n\n## 安装\n\n`composer require yurunsoft/tdengine-restful-connector`\n\n## 使用\n\n**使用连接管理器：**\n\n```php\n// 增加名称为 test 的连接配置\n\\Yurun\\TDEngine\\TDEngineManager::setClientConfig('test', new \\Yurun\\TDEngine\\ClientConfig([\n    // 'host'            =\u003e '127.0.0.1',\n    // 'hostName'        =\u003e '',\n    // 'port'            =\u003e 6041,\n    // 'user'            =\u003e 'root',\n    // 'password'        =\u003e 'taosdata',\n    // 'db'              =\u003e 'database'\n    // 'ssl'             =\u003e false,\n    // 'timestampFormat' =\u003e \\Yurun\\TDEngine\\Constants\\TimeStampFormat::LOCAL_STRING, // 此配置 TDengine 3.0 下失效，统一返回格式为：2022-11-25T05:41:04.690Z\n    // 'keepAlive'       =\u003e true,\n    // 'version'         =\u003e '3', // TDengine 版本\n    // 'timezone'        =\u003e 'UTC', // TDengine \u003e= 3.0 时支持，可选参数，指定返回时间的时区\n]));\n// 设置默认数据库为test\n\\Yurun\\TDEngine\\TDEngineManager::setDefaultClientName('test');\n// 获取客户端对象（\\Yurun\\TDEngine\\Client）\n$client = \\Yurun\\TDEngine\\TDEngineManager::getClient();\n```\n\n**直接 new 客户端：**\n\n```php\n$client = new \\Yurun\\TDEngine\\Client(new \\Yurun\\TDEngine\\ClientConfig([\n    // 'host'            =\u003e '127.0.0.1',\n    // 'hostName'        =\u003e '',\n    // 'port'            =\u003e 6041,\n    // 'user'            =\u003e 'root',\n    // 'password'        =\u003e 'taosdata',\n    // 'db'              =\u003e 'database'\n    // 'ssl'             =\u003e false,\n    // 'timestampFormat' =\u003e \\Yurun\\TDEngine\\Constants\\TimeStampFormat::LOCAL_STRING, // 此配置 TDengine 3.0 下失效，统一返回格式为：2022-11-25T05:41:04.690Z\n    // 'keepAlive'       =\u003e true,\n    // 'version'         =\u003e '3', // TDengine 版本\n    // 'timezone'        =\u003e 'UTC', // TDengine \u003e= 3.0 时支持，可选参数，指定返回时间的时区\n]));\n\n// 通过 sql 方法执行 sql 语句\nvar_dump($client-\u003esql('create database if not exists db_test'));\nvar_dump($client-\u003esql('show databases'));\nvar_dump($client-\u003esql('create table if not exists db_test.tb (ts timestamp, temperature int, humidity float)'));\nvar_dump($client-\u003esql(sprintf('insert into db_test.tb values(%s,%s,%s)', time() * 1000, mt_rand(), mt_rand() / mt_rand())));\n\n$result = $client-\u003esql('select * from db_test.tb');\n\n$result-\u003egetResponse(); // 获取接口原始返回数据\n\n// 获取列数据\nforeach ($result-\u003egetColumns() as $column)\n{\n    $column-\u003egetName(); // 列名\n    $column-\u003egetType(); // 列类型值\n    $column-\u003egetTypeName(); // 列类型名称\n    $column-\u003egetLength(); // 类型长度\n}\n\n// 获取数据\nforeach ($result-\u003egetData() as $row)\n{\n    echo $row['列名']; // 经过处理，可以直接使用列名获取指定列数据\n}\n\n$result-\u003egetStatus(); // 告知操作结果是成功还是失败；同接口返回格式。仅 TDengine 2.x 有用。\n\n$result-\u003egetHead(); // 表的定义，如果不返回结果集，则仅有一列“affected_rows”。（从 2.0.17 版本开始，建议不要依赖 head 返回值来判断数据列类型，而推荐使用 column_meta。在未来版本中，有可能会从返回值中去掉 head 这一项。）；同接口返回格式\n\n$result-\u003egetRows(); // 表明总共多少行数据；同接口返回格式\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurunsoft%2Ftdengine-restful-connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyurunsoft%2Ftdengine-restful-connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurunsoft%2Ftdengine-restful-connector/lists"}