FMDB SQLite question: row count of a query?

前端 未结 8 2048
别那么骄傲
别那么骄傲 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:32

    Please Try Following Code, this works for me

    let objManager = ModelManager.getInstance()
    
    objManager.database?.open()
    
    let resultSet1: FMResultSet! = sharedInstance.database!.executeQuery("SELECT COUNT(Field) FROM TableName”, withArgumentsInArray:nil)
    
            if (resultSet1 != nil)
            {
                while resultSet1.next()
                {
                  countRecord = Int(resultSet1.intForColumn("COUNT(Field)"))
                }
    
            }
    
         print(countRecord)
    

    You Will get Count of Field

提交回复
热议问题