FMDB SQLite问题:查询的行数? [英] FMDB SQLite question: row count of a query?
问题描述
有人知道使用FMDB时如何返回查询的计数吗?如果我执行查询@从某个表中选择count(*)...",我将得到一个空的FMResultSet.如何获取查询的行数?我是否需要执行类似从某处的某处选择*"这样的查询并遍历结果集?还是我可以使用useCount或最佳方式(就性能而言)来做到这一点?
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 the row count of the query? Do I need to do a query like "select * from sometable where.." and iterate through the result set? Or can I use useCount or whats the best way (in terms of performance) to do this?
谢谢!
推荐答案
使用短代码来完成同一件事:
Shorter code to accomplish the same thing:
NSUInteger count = [db intForQuery:@"SELECT COUNT(field) FROM table_name"];
确保包含 FMDatabaseAdditions.h
头文件使用intForQuery:
.
这篇关于FMDB SQLite问题:查询的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!