mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
sqlite: affected rows count (#16426)
This commit is contained in:

committed by
GitHub

parent
1a4d1aece4
commit
f44af02e32
@ -122,6 +122,8 @@ fn C.sqlite3_errmsg(&C.sqlite3) &char
|
||||
|
||||
fn C.sqlite3_free(voidptr)
|
||||
|
||||
fn C.sqlite3_changes(&C.sqlite3) int
|
||||
|
||||
// connect Opens the connection with a database.
|
||||
pub fn connect(path string) !DB {
|
||||
db := &C.sqlite3(0)
|
||||
@ -166,12 +168,17 @@ fn get_int_from_stmt(stmt &C.sqlite3_stmt) int {
|
||||
return res
|
||||
}
|
||||
|
||||
// Returns last insert rowid
|
||||
// last_insert_rowid returns last inserted rowid
|
||||
// https://www.sqlite.org/c3ref/last_insert_rowid.html
|
||||
pub fn (db &DB) last_insert_rowid() i64 {
|
||||
return C.sqlite3_last_insert_rowid(db.conn)
|
||||
}
|
||||
|
||||
// get_affected_rows_count returns `sqlite changes()` meaning amount of rows affected by most recent sql query
|
||||
pub fn (db &DB) get_affected_rows_count() int {
|
||||
return C.sqlite3_changes(db.conn)
|
||||
}
|
||||
|
||||
// Returns a single cell with value int.
|
||||
pub fn (db &DB) q_int(query string) int {
|
||||
stmt := &C.sqlite3_stmt(0)
|
||||
|
Reference in New Issue
Block a user