bing6 / fmdbdatatable Goto Github PK
View Code? Open in Web Editor NEWBased on the FMDB, as long as a few steps can be completed on the single table of the CRUD operation.
License: MIT License
Based on the FMDB, as long as a few steps can be completed on the single table of the CRUD operation.
License: MIT License
根据id 查询 进行删除
error descritions:
DB Error: 1 "near "msgNum": syntax error"
DB Query: update [YHZDBSendInfoRemind] set readTime=:readTime msgNum=:msgNum where remindId = '1498' and serverId = '681'
DB Path:
update two fields in same time would make error like this
FMDTUpdateCommand *cmd = [[YHZDBSet shared].sendInfoRemind createUpdateCommand];
[cmd where:@"remindId" equalTo:object[@"remindId"]];
[cmd where:@"serverId" equalTo:object[@"serverId"]];
[cmd fieldWithKey:@"readTime" val:@"1"];
[cmd fieldWithKey:@"msgNum" val:@"0"];
I found this error in file FMDTUpdateCommand line 180
for (NSString *key in self.dataDict.allKeys) {
[sql appendFormat:@" %@=:%@", key, key];
}
many keys in sql words need "," so 我change this
for (NSString *key in self.dataDict.allKeys) {
[sql appendFormat:@" %@=:%@,", key, key];
}
[sql deleteCharactersInRange:NSMakeRange(sql.length-1, 1)];
在w3cshool里面,
更新某一行中的若干列
我们会修改地址(address),并添加城市名称(city):
UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'
WHERE LastName = 'Wilson'
必须多个并列的时候需要加“,”,源代码中没有加,所以在同时更新多个列时候会出错
亲爱的作者,你好,你的demo下载运行报错,找不到FMDBDataTable文件。
比如数据库里面一条记录某字段为null,该字段 not equal @"1" 这种好像为false,这种应该怎么判断
修改数据库的数据,只能一个,一个字段的修改吗,如果需要同时修改几个字段,用下面这样修改几个字段,在真机上没有效果啊
[ucmd2 fieldWithKey:@"sex" val:@"男"];
[ucmd2 fieldWithKey:@"nickname" val:@"小明"];
能不能FMDataTable改成FMDBDataTable,因为搜FMDB都搜不到你的git,这么好的封装难怪人这么少。
*# -[FMDBModelDBSet flyCity]: unrecognized selector sent to instance 0x140e18440 *
if ([DEFAULTS boolForKey:@"flyCity"] == YES) {
FMDTSelectCommand *cmd = [[TrainCityModelDBSet shared].flyCity createSelectCommand];
[cmd fetchArrayInBackground:^(NSArray *result) {
self.cityArr = result;
}];
return;
}
[MBProgressHUD showMessage:@"正在下载城市列表"];
[HWHttpTool post:QueryPlaneCityList params:nil success:^(id json) {
self.cityArr=[ContactModel mj_objectArrayWithKeyValuesArray:json[@"data"]];
//创建插入对象
FMDTInsertCommand *icmd = [[TrainCityModelDBSet shared].flyCity createInsertCommand];
//添加要插入的对象集合
[icmd addWithArray:self.cityArr];
//设置添加操作是否使用replace语句
[icmd setRelpace:YES];
//执行插入操作
[icmd saveChangesInBackground:^{
[MBProgressHUD hideHUD];
[DEFAULTS setBool:YES forKey:@"flyCity"];
}];
} failure:^(NSError *error) {
[MBProgressHUD hideHUD];
}];
saveChangesInBackground 这个函数是否是有bug?其实它并不是在子线程里执行,一般还是在主线程。这个自定义fmdb的queue只是一个串行自定义队列,会在当前线程执行。也就是说我们按照demo运行在 NSLog处打断点可以看出,实际上是在主线程里执行的
[icmd saveChangesInBackground:^{
NSLog(@"批量数据提交完成");
}];
要在子线程执行,需要修改对应的代码,例如FMDTInsertCommand类修改为:
(void)saveChangesInBackground:(void (^)())complete {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:self.schema.storage];
queue = [[FMDTManager shared] queue];
[queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
@try {
for (FMDTObject *entry in self.dataArray) {
NSArray *array = [self getObjectValues:entry];
NSString *statement = nil;
if (self.relpace) {
statement = self.schema.statementReplace;
} else {
statement = self.schema.statementInsert;
}
[db executeUpdate:statement withArgumentsInArray:array];
}
}
@catch (NSException *exception) {
*rollback = YES;
}
[self.dataArray removeAllObjects];
if (complete) {
complete();
}
}];
});
}
这样就在子线程里运行了,是否我的用法有问题?
不能正常删除
如题
作者你好,FMDBDataTable用在Swift跟OC混合开发会报错,提示找不到FMDTManager.h,请问怎么解决
我代码是这样写:
//清空数据库
FMDTDeleteCommand *dcmd = FMDT_DELETE([DBSet shared].teamPostlistData);
//设置条件
[dcmd where:@"tid" equalTo:teamId];
//执行删除操作
[dcmd saveChanges];
奔溃:
NSString *pk = [(id)cls performSelector:@selector(primaryKeyFieldName) withObject:nil];
FMDTSelectCommand *cmd = [[HLIDataTabeleManger shared].pictureTable createSelectCommand];
NSArray *array = [[cmd where:@"stateFlag" equalTo:@"0"]fetchArray];
亲爱的作者,这句代码,会偶尔出现查询不到数据的情况吗 ,再试一次,就好了 ,我就遇到这样的问题,然后,就不知道他什么时候会出现,导致一些东西不稳定啊 ,以前没有这个问题,就是上次跟新修改数据版本后,就出现了这个问题
第一次建表插入数据出现如下错误是什么原因,如果我把APP重启又可以正常地存储了
DB Error: 1 "no such table: ZQBasePlayerModel"
2016-03-11 16:20:50.574 SporterMan[14464:268791] DB Query: INSERT INTO ZQBasePlayerModel(name,isPlaying,number) VALUES (?,?,?);
2016-03-11 16:20:50.574 SporterMan[14464:268791] 插入失败
例如:
@interface Test : NSObject
@Property (nonatomic, strong) NSString *strTest;
@Property (nonatomic, strong) Message *message;
@Property (nonatomic, strong) Users *users;
@EnD
可以直接调用
[icmd saveChangesInBackground:^{
NSLog(@"批量数据提交完成");
}];
这种也可以直接保存的,因为coredata是支持这种操作的,在比较特殊的时候不想建立多个表关联,这种做法也是挺方便的。
我自己做了测试,在Users实现:
在FMDTInsertCommand.m里边修改
在FMDTSelectCommand.m做对应的NSKeyedUnarchiver即可实现这个功能。是否可以考虑增加上呢?
请问支持多维数组存储吗 ? 比如某个Model里面有个数组属性 也一样存储起来
`- (void)saveChangesInBackground:(void(^)())callback {
if (callback) {
FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:self.schema.storage];
[queue inDatabase:^(FMDatabase *db) {
[db executeUpdate:[self runSql]];
[self.whereArray removeAllObjects];
}];
[queue close];
}
}`
FMDTDeleteCommand 的saveChangesInBackground没有执行Block。
FMDataBase很好用。谢谢。
@Property (nonatomic, assign) int8_t fType;
这样定义的话,CREATE TABLE YHZDBSendInfoInterest (
remindId integer,
fid integer,
fName text,
parentFolderId integer,
parentFolderName text,
operate integer,
operateTime integer,
operatorId integer,
operatorName text,
serverId integer,
readTime integer,
PRIMARY KEY(remindId, serverId)
);
会缺少fType 这个字段,不会自动创建和修改
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.