v orm: select

This commit is contained in:
Alexander Medvednikov 2020-06-17 00:59:33 +02:00
parent 23993d2264
commit ed58192e4c
10 changed files with 304 additions and 44 deletions

View file

@ -37,6 +37,21 @@ pub fn connect(path string) ?DB {
}
}
// Only for V ORM
fn (db DB) init_stmt(query string) &C.sqlite3_stmt {
stmt := &C.sqlite3_stmt(0)
C.sqlite3_prepare_v2(db.conn, query.str, -1, &stmt, 0)
return stmt
}
// Only for V ORM
fn get_int_from_stmt(stmt &C.sqlite3_stmt) int {
C.sqlite3_step(stmt)
res := C.sqlite3_column_int(stmt, 0)
C.sqlite3_finalize(stmt)
return res
}
// Returns a single cell with value int.
pub fn (db DB) q_int(query string) int {
stmt := &C.sqlite3_stmt(0)