ResultRange

An input range interface to access the rows resulting from an SQL query.

The elements of the range are Row structs. A Row is just a view of the current row when iterating the results of a ResultRange. It becomes invalid as soon as ResultRange.popFront() is called (it contains undefined data afterwards). Use cached to store the content of rows past the execution of the statement.

Instances of this struct are typically returned by Database.execute() or Statement.execute().

Members

Functions

empty
bool empty()
front
Row front()

Range interface.

oneValue
auto oneValue()

Gets only the first value of the first row returned by the execution of the statement.

popFront
void popFront()

Range interface.

Examples

1 auto db = Database(":memory:");
2 db.run("CREATE TABLE test (i INTEGER);
3         INSERT INTO test VALUES (1);
4         INSERT INTO test VALUES (2);");
5 
6 auto results = db.execute("SELECT * FROM test");
7 assert(!results.empty);
8 assert(results.front.peek!long(0) == 1);
9 results.popFront();
10 assert(!results.empty);
11 assert(results.front.peek!long(0) == 2);
12 results.popFront();
13 assert(results.empty);

Meta