示例#1
1
 public function __construct($sHost = "localhost", $iPort = 8086, $sUser = '******', $sPassword = '******', $bCheckExistence = true)
 {
     $client = new crodas\InfluxPHP\Client($sHost, $iPort, $sUser, $sPassword);
     if ($bCheckExistence) {
         $aDBs = $client->getDatabases();
         if (isset($aDBs)) {
             foreach ($aDBs as $oDB) {
                 if ($oDB->getName() == 'iws') {
                     print "iws database exists - skipping creation..\n";
                     $this->db = $oDB;
                     return;
                 }
             }
         }
         print "creating missing database for iws ts data..\n";
         $this->db = $client->createDatabase("iws");
         $client->grantPrivilege(crodas\InfluxPHP\Client::PRIV_ALL, "iws", "iws");
     } else {
         $this->db = $client->getDatabase("iws");
     }
 }
示例#2
0
<?php

require __DIR__ . "/../vendor/autoload.php";
$client = new \crodas\InfluxPHP\Client();
$dbs = $client->getDatabases();
if ($dbs) {
    foreach ((array) $dbs as $db) {
        if (preg_match("/^test_/", $db->getName())) {
            $db->drop();
        }
    }
}