前几天做项目,需要获取数据库中本地收藏文章的数量,然后百度到方法,记录一下。
<pre>
+(NSInteger)getLocalCasesCountByTable{
if ([[LPDataBase sharedDatabase].database open]) {
LPUser * user =[KBCoordinatingContext sharedInstance].userInfo;
NSString *selectSQL = [NSString stringWithFormat:@"SELECT Count(*) FROM %@ where UserID = '%@' and Draft = '1'",KTopicList,user.UserID];
return [[LPDataBase sharedDatabase].database intForQuery:selectSQL];
}
return 0;
}
</pre>
[NSString stringWithFormat:@"SELECT Count(*) FROM %@ where UserID = '%@' and Draft = '1'",KTopicList,user.UserID]
KTopicList 表名
user.UserID 参数
网友评论