24 lines
520 B
PHP
24 lines
520 B
PHP
<?php
|
|
|
|
use TDengine\Connection;
|
|
use TDengine\Exception\TDengineException;
|
|
|
|
try {
|
|
// 实例化
|
|
$host = 'localhost';
|
|
$port = 6030;
|
|
$username = 'root';
|
|
$password = 'taosdata';
|
|
$dbname = 'power';
|
|
$connection = new Connection($host, $port, $username, $password, $dbname);
|
|
|
|
// 连接
|
|
$connection->connect();
|
|
|
|
$resource = $connection->query('SELECT ts, current FROM meters LIMIT 2');
|
|
var_dump($resource->fetch());
|
|
} catch (TDengineException $e) {
|
|
// 捕获异常
|
|
throw $e;
|
|
}
|