Skip to content

Commit 2c19dcd

Browse files
isublimityclaude
andcommitted
Add Release 1.26.410 changelog, sync docs with readWithParams()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b35aa19 commit 2c19dcd

5 files changed

Lines changed: 84 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ PHP ClickHouse wrapper - Changelog
22

33
======================
44

5+
### 2026-04-10 [Release 1.26.410]
6+
7+
#### New Features
8+
9+
* **`readWithParams()`** (#254) — stream query results with native ClickHouse typed parameters (`{name:Type}` syntax), combining server-side parameter binding with streaming output (@sander-hash)
10+
11+
#### Code Quality
12+
13+
* **Stringable interfaces** (#252) — all Type classes now explicitly implement `Stringable` for consistency (@sander-hash)
14+
* **PHPStan test fixes** (#253) — removed redundant assertions in static tests, improved assertion quality (@sander-hash)
15+
* **Documentation sync** — updated GitHub Pages (docs/) with `readWithParams()` in native-params, streaming, and per-query-settings guides
16+
17+
#### Merged PRs
18+
19+
* #252 — Add Stringable interfaces for types (@sander-hash)
20+
* #253 — Fix phpstan errors in test files (@sander-hash)
21+
* #254 — Added native params for read function (@sander-hash)
22+
23+
---
24+
525
### 2026-04-06 [Release 1.24.406]
626

727
#### New Features

‎doc/per-query-settings.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ $db->selectWithParams($sql, $params, $querySettings);
3737

3838
// writeWithParams()
3939
$db->writeWithParams($sql, $params, $exception, $querySettings);
40+
41+
// readWithParams()
42+
$db->readWithParams($streamRead, $sql, $params, $querySettings);
4043
```
4144

4245
## Examples

‎docs/native-params.md‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,33 @@ $db->selectWithParams(
7878
);
7979
```
8080

81+
## Streaming with Native Parameters
82+
83+
Use `readWithParams()` to stream query results while still using server-side typed parameters:
84+
85+
```php
86+
$stream = fopen('php://memory', 'r+');
87+
$streamRead = new ClickHouseDB\Transport\StreamRead($stream);
88+
89+
$db->readWithParams(
90+
$streamRead,
91+
'SELECT id, name FROM users WHERE id = {id:UInt32} FORMAT JSONEachRow',
92+
['id' => 1]
93+
);
94+
95+
rewind($stream);
96+
while (($line = fgets($stream)) !== false) {
97+
$row = json_decode(trim($line), true);
98+
echo $row['name'];
99+
}
100+
fclose($stream);
101+
```
102+
103+
The FORMAT clause must be included in the SQL string — unlike `selectWithParams()`, no default format is applied.
104+
81105
## Per-Query Settings
82106

83-
Both methods accept optional settings override:
107+
All three methods accept an optional settings override:
84108

85109
```php
86110
$result = $db->selectWithParams(
@@ -95,6 +119,14 @@ $db->writeWithParams(
95119
true,
96120
['async_insert' => 1, 'wait_for_async_insert' => 0]
97121
);
122+
123+
$stream = fopen('php://memory', 'r+');
124+
$db->readWithParams(
125+
new ClickHouseDB\Transport\StreamRead($stream),
126+
'SELECT id FROM t WHERE id = {id:UInt32} FORMAT JSONEachRow',
127+
['id' => 1],
128+
['max_execution_time' => 300]
129+
);
98130
```
99131

100132
## Native Params vs Bindings
@@ -104,7 +136,7 @@ $db->writeWithParams(
104136
| SQL injection protection | Server-side (protocol level) | Client-side (escaping) |
105137
| Type validation | Server validates types | No validation |
106138
| Syntax | `{name:Type}` in SQL | `:name` or `{name}` in SQL |
107-
| Method | `selectWithParams()` | `select()` |
139+
| Method | `selectWithParams()`, `writeWithParams()`, `readWithParams()` | `select()` |
108140
| Large values | Passed in URL params | Embedded in SQL body |
109141

110142
**Recommendation:** Use native parameters for new code. They are safer and let the server handle type conversion.

‎docs/per-query-settings.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ $db->selectWithParams($sql, $params, $querySettings);
4444

4545
// writeWithParams()
4646
$db->writeWithParams($sql, $params, $exception, $querySettings);
47+
48+
// readWithParams()
49+
$db->readWithParams($streamRead, $sql, $params, $querySettings);
4750
```
4851

4952
## Examples

‎docs/streaming.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ $r = $client->streamRead(
9595
);
9696
```
9797

98+
## readWithParams
99+
100+
Stream query results using native ClickHouse typed parameters (`{name:Type}` syntax). Combines the safety of server-side parameter binding with streaming output:
101+
102+
```php
103+
$stream = fopen('php://memory', 'r+');
104+
$streamRead = new ClickHouseDB\Transport\StreamRead($stream);
105+
106+
$client->readWithParams(
107+
$streamRead,
108+
'SELECT id, name FROM users WHERE id = {id:UInt32} FORMAT JSONEachRow',
109+
['id' => 1]
110+
);
111+
112+
rewind($stream);
113+
while (($line = fgets($stream)) !== false) {
114+
$row = json_decode(trim($line), true);
115+
echo $row['name'];
116+
}
117+
fclose($stream);
118+
```
119+
120+
The FORMAT clause must be specified in the SQL. See [native-params](native-params) for supported parameter types.
121+
98122
## Direct write to file
99123

100124
Send ClickHouse results directly to a file without JSON parsing:

0 commit comments

Comments
 (0)