summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md10
1 files changed, 7 insertions, 3 deletions
diff --git a/README.md b/README.md
index 458d2e2..4938f76 100644
--- a/README.md
+++ b/README.md
@@ -469,7 +469,9 @@ Take the following code:
469var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?"); 469var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?");
470defer stmt.deinit(); 470defer stmt.deinit();
471 471
472const rows = try stmt.all(usize, .{}, .{ 472const allocator = std.heap.page_allocator; // Use a suitable allocator
473
474const rows = try stmt.all(usize, allocator, .{}, .{
473 .age_1 = 10, 475 .age_1 = 10,
474 .age_2 = 20, 476 .age_2 = 20,
475}); 477});
@@ -504,7 +506,9 @@ For example, take the same code as above but now we also bind the last parameter
504var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?"); 506var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?");
505defer stmt.deinit(); 507defer stmt.deinit();
506 508
507const rows = try stmt.all(usize, .{ .allocator = allocator }, .{ 509const allocator = std.heap.page_allocator; // Use a suitable allocator
510
511const rows = try stmt.all(usize, allocator, .{}, .{
508 .age_1 = 10, 512 .age_1 = 10,
509 .age_2 = 20, 513 .age_2 = 20,
510 .weight = false, 514 .weight = false,
@@ -519,7 +523,7 @@ We can make sure the bind parameters have the right type if we rewrite the query
519var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}"); 523var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}");
520defer stmt.deinit(); 524defer stmt.deinit();
521 525
522const rows = try stmt.all(usize, .{ .allocator = allocator }, .{ 526const rows = try stmt.all(usize, allocator, .{}, .{
523 .age_1 = 10, 527 .age_1 = 10,
524 .age_2 = 20, 528 .age_2 = 20,
525 .weight = false, 529 .weight = false,