FMDB SQLite question: row count of a query?

前端 未结 8 2045
别那么骄傲
别那么骄傲 2021-02-01 17:41

does anyone know how to return the count of a query when using FMDB? If I executeQuery @\"select count(*) from sometable were...\" I get an empty FMResultSet back. How can I get

8条回答
  •  醉酒成梦
    2021-02-01 18:23

    updated for Swift 4 minor change in method parameter name

    if let rs = db.executeQuery("SELECT COUNT(*) as Count FROM TABLE_NAME", withArgumentsIn: nil) {
    while rs.next() {
        print("Total Records:", rs.int(forColumn: "Count"))
        }
    }
    

提交回复
热议问题