Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
db57639b48 | |||
830b11c647 | |||
a439f98622 |
15
README.md
15
README.md
|
@ -55,3 +55,18 @@ foreach ($db->query("SELECT * FROM foo;") as $row) {
|
||||||
var_dump($row, $row->time);
|
var_dump($row, $row->time);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Options
|
||||||
|
-------
|
||||||
|
|
||||||
|
- **Timeout** to prevent slow queries from hanging your program:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$client = new \crodas\InfluxPHP\Client(
|
||||||
|
"localhost" /*default*/,
|
||||||
|
8086 /* default */,
|
||||||
|
"root" /* by default */,
|
||||||
|
"root" /* by default */,
|
||||||
|
60 // 60-second timeout (CURLOPT_TIMEOUT)
|
||||||
|
);
|
||||||
|
```
|
|
@ -44,6 +44,8 @@ class BaseHTTP
|
||||||
protected $user;
|
protected $user;
|
||||||
protected $pass;
|
protected $pass;
|
||||||
protected $base;
|
protected $base;
|
||||||
|
protected $timeout;
|
||||||
|
protected $connectTimeout;
|
||||||
protected $timePrecision = 's';
|
protected $timePrecision = 's';
|
||||||
protected $children = array();
|
protected $children = array();
|
||||||
|
|
||||||
|
@ -60,6 +62,8 @@ class BaseHTTP
|
||||||
$this->pass = $c->pass;
|
$this->pass = $c->pass;
|
||||||
$this->port = $c->port;
|
$this->port = $c->port;
|
||||||
$this->host = $c->host;
|
$this->host = $c->host;
|
||||||
|
$this->timeout = $c->timeout;
|
||||||
|
$this->connectTimeout = $c->connectTimeout;
|
||||||
$this->timePrecision = $c->timePrecision;
|
$this->timePrecision = $c->timePrecision;
|
||||||
$c->children[] = $this;
|
$c->children[] = $this;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +75,12 @@ class BaseHTTP
|
||||||
$url .= "?" . http_build_query($args);
|
$url .= "?" . http_build_query($args);
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
if($this->timeout !== null){
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
|
||||||
|
}
|
||||||
|
if($this->connectTimeout !== null){
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
|
||||||
|
}
|
||||||
return $ch;
|
return $ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,17 @@ class Client extends BaseHTTP
|
||||||
protected $port;
|
protected $port;
|
||||||
protected $user;
|
protected $user;
|
||||||
protected $pass;
|
protected $pass;
|
||||||
|
protected $timeout;
|
||||||
|
protected $connectTimeout;
|
||||||
|
|
||||||
public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root')
|
public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root', $timeout = null, $connectTimeout = null)
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
$this->user = $u;
|
$this->user = $u;
|
||||||
$this->pass = $p;
|
$this->pass = $p;
|
||||||
|
$this->timeout = $timeout;
|
||||||
|
$this->connectTimeout = $connectTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteDatabase($name)
|
public function deleteDatabase($name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user