I am using FMDB. I need a function which tells that table is empty or not I tried this. My table is Empty but it writing SomeData
var count = shoppingPad.executeStatements("SELECT COUNT(*) FROM myTable")
print("Count",count)
if(!count )
{
print("EMpty Table")
}
else
{
print("SomeData")
}
ExecuteStatements is for Update/insert statements. to get the data out of the database use ExecuteQuery, which returns the ResultSet, you have to fetch the actual data and then get the integer value of the first row.
let result = database.executeQuery("SELECT COUNT(*) FROM myTable", withArgumentsInArray: [])
if result.next() {
let count = result.intForColumnIndex(0)
if count > 0 {
print("SomeData")
} else {
print("Empty Table")
}
} else {
print("Database error")
}