FMDB SQLite问题:查询的行数? [英] FMDB SQLite question: row count of a query?

查看:84
本文介绍了FMDB SQLite问题:查询的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆