ios - How to check SQLite table is empty or not in Swift -
i using fmdb. need function tells table empty or not tried this. table empty writing somedata
var count = shoppingpad.executestatements("select count(*) mytable") print("count",count) if(!count ) { print("empty table") } else { print("somedata") }
executestatements update/insert statements. data out of database use executequery, returns resultset, have fetch actual data , integer value of first row.
let result = database.executequery("select count(*) mytable", withargumentsinarray: []) if result.next() { let count = result.intforcolumnindex(0) if count > 0 { print("somedata") } else { print("empty table") } } else { print("database error") }
Comments
Post a Comment