uce/site/doc/pages/2_SQLite_query.txt
2026-06-15 21:42:50 +00:00

20 lines
861 B
Plaintext

:sig
DValue SQLite::query(String q)
DValue SQLite::query(String q, const StringMap& params)
:params
q : exactly one SQL statement
params : named :name parameter values; missing keys bind NULL
return value : result rows as a list-shaped DValue, or empty on error/non-row statements
:see
0_SQLite
2_SQLite_error
:content
Prepares and runs exactly one SQL statement. Extra trailing SQL statements are rejected. Parameters must be named `:name` placeholders; positional `?` placeholders are rejected. Result rows are returned as a list of maps keyed by column name. Integer, float, text, blob, and null column types map to matching `DValue` representations where null leaves the field empty. After completion, `affected_rows`, `insert_id`, and `statement_info` are updated.
```cpp
DValue rows = db.query("select * from users where id=:id", {{"id", "42"}});
```