File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public protocol SQLiteType {
5454 func dropIndex( in tableName: String , forColumn columnName: String ) throws
5555 func beginTransaction( ) throws
5656 func endTransaction( ) throws
57- func insertRow( sql: String , valuesToBind: SQLValues ? ) throws
57+ func insertRow( sql: String , valuesToBind: SQLValues ? ) throws -> Int
5858 func updateRow( sql: String , valuesToBind: SQLValues ? ) throws
5959 func deleteRow( sql: String , valuesToBind: SQLValues ? ) throws
6060 func deleteByID( in tableName: String , id: Int ) throws
@@ -291,9 +291,11 @@ open class SQLite: SQLiteType {
291291 }
292292
293293 /// Can be used to insert one or several rows depending on the SQL statement
294- public func insertRow( sql: String , valuesToBind: SQLValues ? = nil ) throws {
294+ /// - Returns: The id for the last inserted row
295+ public func insertRow( sql: String , valuesToBind: SQLValues ? = nil ) throws -> Int {
295296 try operation ( sql: sql, valuesToBind: valuesToBind)
296297 log ( " successfully inserted row(s), sql: \( sql) " )
298+ return Int ( sqlite3_last_insert_rowid ( dbPointer) )
297299 }
298300
299301 /// Can be used to update one or several rows depending on the SQL statement
You can’t perform that action at this time.
0 commit comments