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
Exemplo n.º 1
0
 /**
  * @see https://github.com/influxdata/influxdb-php/pull/36
  */
 public function testReservedNames()
 {
     $database = new Database('stats', $this->mockClient);
     // test handling of reserved keywords in database name
     $database->create();
     $this->assertEquals('CREATE DATABASE IF NOT EXISTS "stats"', Client::$lastQuery);
     $database->listRetentionPolicies();
     $this->assertEquals('SHOW RETENTION POLICIES ON "stats"', Client::$lastQuery);
     // test handling of reserved keywords in retention policy names
     $database->create($this->getTestRetentionPolicy('default'));
     $this->assertEquals('CREATE RETENTION POLICY "default" ON "stats" DURATION 1d REPLICATION 1 DEFAULT', Client::$lastQuery);
     // test handling of reserved keywords in measurement names
     $this->assertEquals($database->getQueryBuilder()->from('server')->getQuery(), 'SELECT * FROM "server"');
 }