Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

feat: possibility to pass request method to influxDB query #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/InfluxDB/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ public function selectDB($name)
*
* @param string $database
* @param string $query
* @param string $method
* @param array $parameters
*
* @return ResultSet
* @throws Exception
*/
public function query($database, $query, $parameters = [])
public function query($database, $query, $parameters = [], $method = 'get')
{
$driver = $this->getDriver();

Expand All @@ -175,7 +176,7 @@ public function query($database, $query, $parameters = [])
$parameters = [
'url' => 'query?' . http_build_query(array_merge(['q' => $query], $parameters)),
'database' => $database,
'method' => 'get'
'method' => $method
];

// add authentication to the driver if needed
Expand Down
13 changes: 7 additions & 6 deletions src/InfluxDB/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ public function getName()
*
* @param string $query
* @param array $params
* @param string $method
* @return ResultSet
* @throws Exception
*/
public function query($query, $params = [])
public function query($query, $params = [], $method = 'get')
{
return $this->client->query($this->name, $query, $params);
return $this->client->query($this->name, $query, $params, $method);
}

/**
Expand All @@ -94,7 +95,7 @@ public function create(RetentionPolicy $retentionPolicy = null, $createIfNotExis
try {
$query = sprintf('CREATE DATABASE "%s"', $this->name);

$this->query($query);
$this->query($query, [], 'post');

if ($retentionPolicy) {
$this->createRetentionPolicy($retentionPolicy);
Expand All @@ -114,7 +115,7 @@ public function create(RetentionPolicy $retentionPolicy = null, $createIfNotExis
*/
public function createRetentionPolicy(RetentionPolicy $retentionPolicy)
{
return $this->query($this->getRetentionPolicyQuery('CREATE', $retentionPolicy));
return $this->query($this->getRetentionPolicyQuery('CREATE', $retentionPolicy), [], 'post');
}

/**
Expand Down Expand Up @@ -193,7 +194,7 @@ public function exists()
*/
public function alterRetentionPolicy(RetentionPolicy $retentionPolicy)
{
$this->query($this->getRetentionPolicyQuery('ALTER', $retentionPolicy));
$this->query($this->getRetentionPolicyQuery('ALTER', $retentionPolicy), [], 'post');
}

/**
Expand All @@ -210,7 +211,7 @@ public function listRetentionPolicies()
*/
public function drop()
{
$this->query(sprintf('DROP DATABASE "%s"', $this->name));
$this->query(sprintf('DROP DATABASE "%s"', $this->name), [], 'post');
}

/**
Expand Down