PHP Class InfluxDB\Database

Author: Stephen "TheCodeAssassin" Hoogendijk
Mostra file Open project: influxdb/influxdb-php Class Usage Examples

Protected Properties

Property Type Description
$client Client
$name string The name of the Database

Public Methods

Method Description
__construct ( string $name, Client $client ) Construct a database object
alterRetentionPolicy ( InfluxDB\Database\RetentionPolicy $retentionPolicy )
create ( InfluxDB\Database\RetentionPolicy $retentionPolicy = null, boolean $createIfNotExists = true ) : influxdb\ResultSet Create this database
createRetentionPolicy ( InfluxDB\Database\RetentionPolicy $retentionPolicy ) : influxdb\ResultSet
drop ( ) Drop this database
exists ( ) : boolean
getClient ( ) : Client
getName ( ) : string
getQueryBuilder ( ) : InfluxDB\Query\Builder Retrieve the query builder
listRetentionPolicies ( ) : array
query ( string $query, array $params = [] ) : influxdb\ResultSet Query influxDB
writePayload ( string | array $payload, string $precision = self::PRECISION_NANOSECONDS, string | null $retentionPolicy = null ) : boolean Write a payload into InfluxDB using the current driver. This method is similar to writePoints(), except it takes a string payload instead of an array of Points. This is useful in the following situations:
writePoints ( array $points, string $precision = self::PRECISION_NANOSECONDS, string | null $retentionPolicy = null ) : boolean Write points into InfluxDB using the current driver. This is the recommended method for inserting data into InfluxDB.

Protected Methods

Method Description
getRetentionPolicyQuery ( string $method, InfluxDB\Database\RetentionPolicy $retentionPolicy ) : string

Method Details

__construct() public method

Construct a database object
public __construct ( string $name, Client $client )
$name string
$client Client

alterRetentionPolicy() public method

public alterRetentionPolicy ( InfluxDB\Database\RetentionPolicy $retentionPolicy )
$retentionPolicy InfluxDB\Database\RetentionPolicy

create() public method

Create this database
public create ( InfluxDB\Database\RetentionPolicy $retentionPolicy = null, boolean $createIfNotExists = true ) : influxdb\ResultSet
$retentionPolicy InfluxDB\Database\RetentionPolicy
$createIfNotExists boolean Only create the database if it does not yet exist
return influxdb\ResultSet

createRetentionPolicy() public method

public createRetentionPolicy ( InfluxDB\Database\RetentionPolicy $retentionPolicy ) : influxdb\ResultSet
$retentionPolicy InfluxDB\Database\RetentionPolicy
return influxdb\ResultSet

drop() public method

Drop this database
public drop ( )

exists() public method

public exists ( ) : boolean
return boolean

getClient() public method

public getClient ( ) : Client
return Client

getName() public method

public getName ( ) : string
return string

getQueryBuilder() public method

Retrieve the query builder
public getQueryBuilder ( ) : InfluxDB\Query\Builder
return InfluxDB\Query\Builder

getRetentionPolicyQuery() protected method

protected getRetentionPolicyQuery ( string $method, InfluxDB\Database\RetentionPolicy $retentionPolicy ) : string
$method string
$retentionPolicy InfluxDB\Database\RetentionPolicy
return string

listRetentionPolicies() public method

public listRetentionPolicies ( ) : array
return array

query() public method

Query influxDB
public query ( string $query, array $params = [] ) : influxdb\ResultSet
$query string
$params array
return influxdb\ResultSet

writePayload() public method

1) Performing unique queries that may not conform to the current Point standard. 2) Inserting very large set of points into a measurement where looping via array_map() actually hurts performance as the payload may be calculated in advance by caller.
public writePayload ( string | array $payload, string $precision = self::PRECISION_NANOSECONDS, string | null $retentionPolicy = null ) : boolean
$payload string | array InfluxDB payload (Or array of payloads) that conform to the Line syntax.
$precision string The timestamp precision (defaults to nanoseconds).
$retentionPolicy string | null Specifies an explicit retention policy to use when writing all points. If not set, the default retention period will be used. This is only applicable for the Guzzle driver. The UDP driver utilizes the endpoint configuration defined in the server's influxdb configuration file.
return boolean

writePoints() public method

Write points into InfluxDB using the current driver. This is the recommended method for inserting data into InfluxDB.
public writePoints ( array $points, string $precision = self::PRECISION_NANOSECONDS, string | null $retentionPolicy = null ) : boolean
$points array Array of Point objects
$precision string The timestamp precision (defaults to nanoseconds).
$retentionPolicy string | null Specifies an explicit retention policy to use when writing all points. If not set, the default retention period will be used. This is only applicable for the Guzzle driver. The UDP driver utilizes the endpoint configuration defined in the server's influxdb configuration file.
return boolean

Property Details

$client protected_oe property

protected Client,influxdb $client
return Client

$name protected_oe property

The name of the Database
protected string $name
return string