gpt4 book ai didi

ios - 如何查看以下 FMDatabase executeUpdate 语句是否成功?

转载 作者:行者123 更新时间:2023-11-28 19:48:45 26 4
gpt4 key购买 nike

下面的代码没有给出任何错误,但没有执行插入操作,我不明白为什么。我还是个新手,想知道查看此查询结果或查看是否有错误消息的最佳方法。我确定它很简单,例如“BOOL success = [database executeUpdate...] 然后打印 BOOL。提前致谢。

if ([database open]) {
[database executeUpdate:@"insert into CONDITION (condition_id, condition_name, condition_detail, condition_area, condition_date, active) values(?, ?, ?, ?, ?)",
[NSNumber numberWithInt:self.condition_id], self.condition_name, self.condition_detail, self.condition_area, self.condition_date, [NSNumber numberWithInt:myInt] ];

[database close];

最佳答案

executeUpdate 方法有返回值并且 FMDatabase 保存了 lastErrorMessage:

BOOL isSuccessful = [database executeUpdate:@"insert into CONDITION (condition_id, condition_name, condition_detail, condition_area, condition_date, active) values(?, ?, ?, ?, ?)",
[NSNumber numberWithInt:self.condition_id], self.condition_name, self.condition_detail, self.condition_area, self.condition_date, [NSNumber numberWithInt:myInt] ];
if (!isSuccessful) {
NSLog(@"%@", database.lastErrorMessage);
}

关于ios - 如何查看以下 FMDatabase executeUpdate 语句是否成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30413888/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com