chromabits/influx-php

InfluxDB的简单客户端

0.2.1 2015-01-16 22:48 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:13:40 UTC


README

这是一个针对InfluxDB的简单PHP客户端,InfluxDB是一个开源的、分布式的、时间序列、事件和指标数据库。

这是对crodas/InfluxPHP的分支。

安装

最简单的方式是通过composer来安装。

composer require chromabits/influx-php

使用方法

您需要创建一个客户端对象。

use Chromabits\InfluxClient\Client;

$client = new Client(
   "localhost" /*default*/,
   8086 /* default */,
   "root" /* by default */,
   "root" /* by default */
);

第一次需要创建一个数据库。

$db = $client->createDatabase("foobar");
$db->createUser("foo", "bar"); // <-- create user/password

创建数据非常简单。

$db = $client->foobar;
$db->insert("some label", ['foobar' => 'bar']); // single input
$db->insert("some label", [
    ['foobar' => 'bar'],
    ['foobar' => 'foo'],
]); // multiple input, this is better :-)

现在您可以获取数据库对象并开始查询。

$db = $client->foobar;
// OR
$db = $client->getDatabase("foobar");

foreach ($db->query("SELECT * FROM foo;") as $row) {
    var_dump($row, $row->time);
}