query.php 520 字节
Newer Older
weixin_47267244's avatar
weixin_47267244 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?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;
}