InfluxDB\Client::getDriver PHP Method

getDriver() public method

public getDriver ( ) : InfluxDB\Driver\DriverInterface | InfluxDB\Driver\QueryDriverInterface
return InfluxDB\Driver\DriverInterface | InfluxDB\Driver\QueryDriverInterface
    public function getDriver()
    {
        return $this->driver;
    }

Usage Example

Example #1
0
 /**
  * Writes points into InfluxDB
  *
  * @param  Point[] $points    Array of points
  * @param  string  $precision The timestamp precision (defaults to nanoseconds)
  * @return bool
  * @throws Exception
  */
 public function writePoints(array $points, $precision = self::PRECISION_NANOSECONDS)
 {
     $payload = array_map(function (Point $point) {
         return (string) $point;
     }, $points);
     try {
         $driver = $this->client->getDriver();
         $driver->setParameters(['url' => sprintf('write?db=%s&precision=%s', $this->name, $precision), 'database' => $this->name, 'method' => 'post']);
         // send the points to influxDB
         $driver->write(implode(PHP_EOL, $payload));
         return $driver->isSuccess();
     } catch (\Exception $e) {
         throw new Exception('Writing has failed', $e->getCode(), $e);
     }
 }
All Usage Examples Of InfluxDB\Client::getDriver