Added support to use timePrecision in POSTs (inserts) too
This commit is contained in:
parent
6b05c2166c
commit
e95ca5c715
|
@ -64,7 +64,7 @@ class BaseHTTP
|
|||
$c->children[] = $this;
|
||||
}
|
||||
|
||||
protected function getCurl($url, Array $args = [])
|
||||
protected function getCurl($url, array $args = [])
|
||||
{
|
||||
$args = array_merge($args, ['u' => $this->user, 'p' => $this->pass]);
|
||||
$url = "http://{$this->host}:{$this->port}/{$this->base}{$url}";
|
||||
|
@ -116,18 +116,18 @@ class BaseHTTP
|
|||
return $this;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("Expecting m,s or u");
|
||||
throw new \InvalidArgumentException("Expecting s, m or u as time precision");
|
||||
}
|
||||
|
||||
protected function get($url, Array $args = [])
|
||||
protected function get($url, array $args = [])
|
||||
{
|
||||
$ch = $this->getCurl($url, $args);
|
||||
return $this->execCurl($ch, true);
|
||||
}
|
||||
|
||||
protected function post($url, Array $body)
|
||||
protected function post($url, array $body, array $args = [])
|
||||
{
|
||||
$ch = $this->getCurl($url);
|
||||
$ch = $this->getCurl($url, $args);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => json_encode($body),
|
||||
|
|
|
@ -41,7 +41,7 @@ use ArrayIterator;
|
|||
|
||||
class Cursor extends ArrayIterator
|
||||
{
|
||||
public function __construct(Array $resultset)
|
||||
public function __construct(array $resultset)
|
||||
{
|
||||
$rows = [];
|
||||
foreach ($resultset as $set) {
|
||||
|
|
|
@ -60,7 +60,7 @@ class DB extends BaseHTTP
|
|||
return $this->client->deleteDatabase($this->name);
|
||||
}
|
||||
|
||||
public function insert($name, Array $data)
|
||||
public function insert($name, array $data)
|
||||
{
|
||||
$points = [];
|
||||
$first = current($data);
|
||||
|
@ -72,7 +72,7 @@ class DB extends BaseHTTP
|
|||
$points[] = array_values($value);
|
||||
}
|
||||
$body = compact('name', 'columns', 'points');
|
||||
return $this->post('series', [$body]);
|
||||
return $this->post('series', [$body], ['time_precision' => $this->timePrecision]);
|
||||
}
|
||||
|
||||
public function first($sql)
|
||||
|
|
Loading…
Reference in New Issue
Block a user