Skip to content

Commit 769216c

Browse files
committed
Added getChanges() and getTotalChanges()
1 parent 5be5466 commit 769216c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Sources/SQLiteAdapter/SQLiteAdapter.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public protocol SQLiteType {
6767
func getByID(from table: SQLTable, id: Int) throws -> SQLValues
6868
func getLastRow(from table: SQLTable) throws -> SQLValues
6969
func getLastInsertID() -> Int
70+
func getChanges() -> Int
71+
func getTotalChanges() -> Int
7072
func vacuum() throws
7173
func resetAutoincrement(in table: SQLTable) throws
7274
func query(sql: String, params: [Any]?) throws
@@ -499,6 +501,16 @@ open class SQLite: SQLiteType {
499501
return Int(sqlite3_last_insert_rowid(dbPointer))
500502
}
501503

504+
/// Returns number of rows changed by last INSERT, UPDATE or DELETE statement
505+
public func getChanges() -> Int {
506+
return Int(sqlite3_changes(dbPointer))
507+
}
508+
509+
/// Returns number of rows changed by INSERT, UPDATE or DELETE statements since the DB was opened
510+
public func getTotalChanges() -> Int {
511+
return Int(sqlite3_total_changes(dbPointer))
512+
}
513+
502514
/// Repacks the DB to take advantage of deleted data
503515
public func vacuum() throws {
504516
let sql = "VACUUM;"

0 commit comments

Comments
 (0)