Skip to content

Commit 5aacf38

Browse files
committed
ok
1 parent b53fe27 commit 5aacf38

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@ and have not dependencies (may be used independently, file src/ClichHouseAPI.php
1010
* **setServerUrl**($url) - set ClickHouse server parameters by url (host, port, etc.)
1111
* **getQuery**($h_query [, $sess]) - send GET request
1212
* **postQuery**($h_query, $post_data [, $sess]) - send POST request
13-
##### Sessions:
13+
#### Special functions
14+
* **getVersion**() - return version of ClickHouse server (side effect - detect server features)
15+
* **isSupported**(feature-name) - true or false depending on the server support features.
16+
##### If isSupported('session_id'):
1417
* **getSession**() - get current session_id from options
1518
* **setSession**([$sess]) - set session_id or generate new session_id and set it
1619
##### Options:
17-
* **setOption**($key, $value) - set http-option for requests
18-
* **getOption**($key) - get http-option value
20+
* **setOption**($key, $value) - set http-option for all next requests
21+
* **getOption**($key) - get current http-option value
1922
* **delOption**($key) - delete http-option (same ->setOption($key, null)
2023

2124
### Class **ClickHouseQuery**
2225
Class **ClickHouseQuery** contains wrapper for ClickHouseAPI and allow to easily
2326
send queries to ClickHouse server and parsing answering data.
2427

2528
#### Main query-functions for use:
26-
* **queryTrue**($sql, [post]) - Return false only if error, otherwise return true or data
27-
* **queryFalse**($sql, [post])- Return false only if NOT error, otherwise string with error.
28-
* **queryValue**($sql, [post]) - Send query and receive data in one string (false if error)
29-
* **queryArray**($sql) - for queries returning multi-rows data
30-
* **queryKeyValues**(see descr.) - for queries returning 2 columns key => value
29+
* **queryFalse**($sql, [post])- for queries that should not return anything. False if ok, or error string.
30+
* **queryTrue**($sql, [post]) - return false only if error, otherwise return true or response data.
31+
* **queryValue**($sql, [post]) - send any query and receive all data in one string (false if error)
32+
* **queryArray**($sql) - for queries returning structured data (usually one or more table rows)
33+
* **queryKeyValues**(see descr.) - for queries returning 2 columns, first means as key, second as value
3134
* **queryInsertArray**($table, $fields_names, $fields_set) - insert data into table from array
3235
* **queryInsertFile**($table, $file, $structure) - insert data from file into table
3336

@@ -48,7 +51,6 @@ contains functions for simple operations with ClickHouse.
4851
* **getDatabasesList**() - returns array contained names of existing Databases
4952
* **setCurrentDatabase**($db [, $sess]) - set current database by 'USE db' request
5053
* **getCurrentDatabase**([$sess]) - return results of 'SELECT currentDatabase()'
51-
* **getVersion**() - return version of ClickHouse server
5254
* **getUptime**() - return server uptime in seconds
5355
* **getSystemSettings**() - get information from system.settings as array [name=>value]
5456

src/ClickHouseAPI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ClickHouseAPI
102102
/**
103103
* CURL option CURLOPT_CONNECTTIMEOUT
104104
*
105-
* @var integer 2 sec. by default
105+
* @var integer 3 sec. by default
106106
*/
107107
public $curl_conn_timeout = 3;
108108

tests/src/ClickHouseFunctionsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public function testCreateDatabase()
110110

111111
$tmpdb = 'tmpdbfordel';
112112

113-
$this->assertFalse($ch->createDatabase($tmpdb, true));
114-
115-
$db_arr = $ch->getDatabasesList();
113+
if ($ch->isSupported('query')) {
114+
$this->assertFalse($ch->createDatabase($tmpdb, true));
116115

117-
$this->assertTrue(array_search($tmpdb, $db_arr) !== false);
116+
$db_arr = $ch->getDatabasesList();
118117

119-
// $this->assertFalse($ch->dropDatabase($tmpdb));
118+
$this->assertTrue(array_search($tmpdb, $db_arr) !== false);
119+
}
120120
}
121121

122122
/**
@@ -128,11 +128,11 @@ public function testDropDatabase()
128128

129129
$tmpdb = 'tmpdbfordel';
130130

131-
// $this->assertFalse($ch->createDatabase($tmpdb, true));
132-
133-
$this->assertFalse($ch->dropDatabase($tmpdb));
134-
$db_arr = $ch->getDatabasesList();
135-
$this->assertFalse(array_search($tmpdb, $db_arr));
131+
if ($ch->isSupported('query')) {
132+
$this->assertFalse($ch->dropDatabase($tmpdb));
133+
$db_arr = $ch->getDatabasesList();
134+
$this->assertFalse(array_search($tmpdb, $db_arr));
135+
}
136136
}
137137

138138
/**

0 commit comments

Comments
 (0)