diff options
| author | 2024-12-14 01:33:55 +0100 | |
|---|---|---|
| committer | 2024-12-14 01:33:55 +0100 | |
| commit | a948faa6790b3b694f6f6098936f2045c183f932 (patch) | |
| tree | d8505d044f4845cb096c651853714fce02d5b71a /README.md | |
| parent | readme: fix examples (diff) | |
| download | zig-sqlite-a948faa6790b3b694f6f6098936f2045c183f932.tar.gz zig-sqlite-a948faa6790b3b694f6f6098936f2045c183f932.tar.xz zig-sqlite-a948faa6790b3b694f6f6098936f2045c183f932.zip | |
readme: fix examples
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 6 |
1 files changed, 5 insertions, 1 deletions
| @@ -523,6 +523,8 @@ We can make sure the bind parameters have the right type if we rewrite the query | |||
| 523 | var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}"); | 523 | var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}"); |
| 524 | defer stmt.deinit(); | 524 | defer stmt.deinit(); |
| 525 | 525 | ||
| 526 | const allocator = std.heap.page_allocator; // Use a suitable allocator | ||
| 527 | |||
| 526 | const rows = try stmt.all(usize, allocator, .{}, .{ | 528 | const rows = try stmt.all(usize, allocator, .{}, .{ |
| 527 | .age_1 = 10, | 529 | .age_1 = 10, |
| 528 | .age_2 = 20, | 530 | .age_2 = 20, |
| @@ -567,7 +569,9 @@ To finish our example, passing the proper type allows it compile: | |||
| 567 | var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}"); | 569 | var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}"); |
| 568 | defer stmt.deinit(); | 570 | defer stmt.deinit(); |
| 569 | 571 | ||
| 570 | const rows = try stmt.all(usize, .{}, .{ | 572 | const allocator = std.heap.page_allocator; // Use a suitable allocator |
| 573 | |||
| 574 | const rows = try stmt.all(usize, allocator, .{}, .{ | ||
| 571 | .age_1 = 10, | 575 | .age_1 = 10, |
| 572 | .age_2 = 20, | 576 | .age_2 = 20, |
| 573 | .weight = @as(usize, 200), | 577 | .weight = @as(usize, 200), |