@@ -13,10 +13,7 @@ exist. Possibility to enable a shared cache.
13132 . ` Database ` has facility functions create new functions, aggregates or collations.
1414
15153 . ` Query ` is a wrapper around prepared statements and their results, with functionality
16- to:
17- - bind parameters: ` params.bind `
18- - iterate on result rows with an InputRange interface: ` rows `
19- - convert column to D type: ` get `
16+ to bind parameters, iterate on result rows with an InputRange interface and convert column value to a D type.
2017
2118### Synopsis
2219``` d
6057 );
6158
6259 // Bind everything with chained calls to params.bind().
63- query.params. bind(":last_name", "Smith")
64- .bind(":first_name", "John")
65- .bind(":score", 77.5);
60+ query.bind(":last_name", "Smith");
61+ query .bind(":first_name", "John");
62+ query .bind(":score", 77.5);
6663 ubyte[] photo = cast(ubyte[]) "..."; // Store the photo as raw array of data.
67- query.params. bind(":photo", photo);
64+ query.bind(":photo", photo);
6865 query.execute();
6966
7067 query.reset(); // Need to reset the query after execution.
71- query.params. bind(":last_name", "Doe")
72- .bind(":first_name", "John")
73- .bind(3, null) // Use of index instead of name.
74- .bind(":photo", null);
68+ query.bind(":last_name", "Doe");
69+ query .bind(":first_name", "John");
70+ query .bind(3, null); // Use of index instead of name.
71+ query .bind(":photo", null);
7572 query.execute();
7673}
7774catch (SqliteException e)
9895 auto name = format("%s, %s", row["last_name"].get!string(), row["first_name"].get!(char[])());
9996 // The score can be NULL, so provide 0 (instead of NAN) as a default value to replace NULLs:
10097 auto score = row["score"].get!real(0.0);
101- // Use of opDispatch with column name:
98+ // Use opDispatch to retrieve a column from its name
10299 auto photo = row.photo.get!(ubyte[])();
103100
104101 // ... and use all these data!
0 commit comments